HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_CodecRegistry.h
Go to the documentation of this file.
1 #ifndef __GLTF_CodecRegistry_h__
2 #define __GLTF_CodecRegistry_h__
3 
4 #include "GLTFZ_API.h"
5 
6 #include <UT/UT_Array.h>
7 #include <UT/UT_StringHolder.h>
8 #include <UT/UT_UniquePtr.h>
9 
10 #define GLTF_REGISTER_CODEC(cls, name) \
11  struct cls##_CodecEntryInstantiator \
12  { \
13  cls##_CodecEntryInstantiator() \
14  { \
15  UT_UniquePtr<GLTF_CodecRegistry::EntryBase> cls##_CodecEntry( \
16  new GLTF_CodecRegistry::Entry<cls>(name)); \
17  GLTFgetCodecRegistry()->registerEntry(std::move(cls##_CodecEntry)); \
18  } \
19  }; \
20  static cls##_CodecEntryInstantiator the##cls##CodecEntry;
21 
23 {
24 public:
25 
26  class EntryBase
27  {
28  public:
29  EntryBase(const char* name)
30  : myCodecName(name) {}
31  virtual ~EntryBase() {}
32  virtual bool isExtensionSupported(const char* ext_name) const = 0;
33 
34  private:
35 
36  UT_StringHolder myCodecName;
37  };
38 
39  template <typename T>
40  class Entry : public EntryBase
41  {
42  public:
43  Entry(const char* name)
44  : EntryBase(name)
45  {
46 
47  }
48  ~Entry() override = default;
49 
50  bool isExtensionSupported(const char* ext_name) const override
51  {
52  return T::isExtensionSupported(ext_name);
53  }
54  };
55 
56 public:
57 
58  GLTF_CodecRegistry() = default;
59  ~GLTF_CodecRegistry() = default;
60  GLTF_CodecRegistry(const GLTF_CodecRegistry& other) = delete;
61  GLTF_CodecRegistry& operator=(const GLTF_CodecRegistry& other) = delete;
62  GLTF_CodecRegistry(GLTF_CodecRegistry&& other) = default;
63 
64  void registerEntry(UT_UniquePtr<EntryBase>&& entry);
65  bool isExtensionSupported(const char* ext_name) const;
66 
67 private:
68 
70 
71 };
72 
74 
75 #endif // __GLTF_CodecRegistry_h__
virtual ~EntryBase()
GLTFZ_API GLTF_CodecRegistry * GLTFgetCodecRegistry()
EntryBase(const char *name)
Entry(const char *name)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
bool isExtensionSupported(const char *ext_name) const override
GLuint const GLchar * name
Definition: glcorearb.h:786
LeafData & operator=(const LeafData &)=delete
#define GLTFZ_API
Definition: GLTFZ_API.h:37