UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
type.h
Go to the documentation of this file.
1 
2 #ifndef UGDK_SCRIPT_VIRTUALTYPE_H_
3 #define UGDK_SCRIPT_VIRTUALTYPE_H_
4 
5 #include <vector>
6 
7 #include <ugdk/script/defs.h>
8 
9 namespace ugdk {
10 
11 namespace script {
12 
13 class VirtualType {
14 
15  public:
16 
17  VirtualType() : types_(10, (struct swig_type_info*)nullptr) {}
19 
20  struct swig_type_info* FromLang(LangID id) const {
21  return types_[id];
22  }
23 
24  void RegisterFromLang(struct swig_type_info* info, LangID id) {
25  if (!types_[id]) types_[id] = info;
26  }
27 
28  private:
29 
30  typedef std::vector<struct swig_type_info*> TypeFromLang;
31 
32  TypeFromLang types_;
33 
34 };
35 
36 
37 template <class T>
38 class TypeRegistry {
39 
40  public:
41 
42  static VirtualType& type () {
43  return type_;
44  }
45 
46  private:
47 
48  TypeRegistry () {}
49 
50  static VirtualType type_;
51 
52 };
53 
54 template <class T>
55 VirtualType TypeRegistry<T>::type_;
56 
57 } /* namespace script */
58 
59 } /* namespace ugdk */
60 
61 template <class T>
62 static void RegisterType(T* tp) {
63  (void)tp;
64 }
65 
66 template <typename T>
67 T* GetNull () { return nullptr; }
68 
69 #endif /* UGDK_SCRIPT_VIRTUALTYPE_H_ */
~VirtualType()
Definition: type.h:18
Definition: type.h:38
Definition: animation.h:11
Definition: type.h:13
struct swig_type_info * FromLang(LangID id) const
Definition: type.h:20
void RegisterFromLang(struct swig_type_info *info, LangID id)
Definition: type.h:24
size_t LangID
Type used for script languages' IDs.
Definition: defs.h:26
VirtualType()
Definition: type.h:17
static VirtualType & type()
Definition: type.h:42
T * GetNull()
Definition: type.h:67