HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_IO.h
Go to the documentation of this file.
1 #ifndef __GLTF_IO_h__
2 #define __GLTF_IO_h__
3 
4 #include "GLTFZ_API.h"
5 #include "GLTF_CgltfWrapper.h"
6 
7 #include <UT/UT_UniquePtr.h>
8 
10 
12 {
13 public:
14  enum class Mode : int
15  {
16  Invalid,
17  Read,
18  Write
19  };
20 
21  explicit GLTF_IO(GLTF_IO::Mode mode);
22  ~GLTF_IO() {}
23 
24  bool open(const char* path, GLTF_ErrorManager& errors);
25  void close();
26 
27  bool isOpen() const { return myCgltfWrapper != nullptr; }
28 
29  bool read(GLTF_ErrorManager& errors);
30  bool write(GLTF_ErrorManager& errors);
31 
32  UT_StringHolder getFilename() const;
33  UT_StringHolder getFileExtension() const;
34 
36  {
37  if (!myCgltfWrapper)
38  return nullptr;
39 
40  return myCgltfWrapper->getCgltfData();
41  }
42  const cgltf_data* getCgltfData() const
43  {
44  if (!myCgltfWrapper)
45  return nullptr;
46 
47  return myCgltfWrapper->getCgltfData();
48  }
49 
51  {
52  if (!myCgltfWrapper)
53  return nullptr;
54 
55  return &myCgltfWrapper->getCgltfOptions();
56  }
58  {
59  if (!myCgltfWrapper)
60  return nullptr;
61 
62  return &myCgltfWrapper->getCgltfOptions();
63  }
64 
65  GLTF_CgltfWrapper* getCgltfWrapper() { return myCgltfWrapper.get(); }
66 
67 private:
68 
69  bool openForRead(GLTF_ErrorManager& errors);
70  bool openForWrite(GLTF_ErrorManager& errors);
71 
72 private:
73  Mode myMode = Mode::Invalid;
74  UT_UniquePtr<GLTF_CgltfWrapper> myCgltfWrapper = nullptr;
75 
76  UT_StringHolder myFilePath;
77 };
78 
79 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
bool isOpen() const
Definition: GLTF_IO.h:27
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
void close() override
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
int open(float queuesize) override
cgltf_data * getCgltfData()
Definition: GLTF_IO.h:35
cgltf_options * getCgltfOptions()
Definition: GLTF_IO.h:50
GLTF_CgltfWrapper * getCgltfWrapper()
Definition: GLTF_IO.h:65
const cgltf_options * getCgltfOptions() const
Definition: GLTF_IO.h:57
GLenum mode
Definition: glcorearb.h:99
~GLTF_IO()
Definition: GLTF_IO.h:22
#define GLTFZ_API
Definition: GLTFZ_API.h:37
const cgltf_data * getCgltfData() const
Definition: GLTF_IO.h:42