UGDK
src/ugdk/script/type.h
Go to the documentation of this file.
00001 
00002 #ifndef UGDK_SCRIPT_VIRTUALTYPE_H_
00003 #define UGDK_SCRIPT_VIRTUALTYPE_H_
00004 
00005 #include <vector>
00006 
00007 #include <ugdk/script/defs.h>
00008 
00009 namespace ugdk {
00010 
00011 namespace script {
00012 
00013 class VirtualType {
00014 
00015   public:
00016 
00017     VirtualType() : types_(10, (struct swig_type_info*)NULL) {}
00018     ~VirtualType() {}
00019 
00020     struct swig_type_info* FromLang(LangID id) const {
00021         return types_[id];
00022     }
00023 
00024     void RegisterFromLang(struct swig_type_info* info, LangID id) {
00025         if (!types_[id]) types_[id] = info;
00026     }
00027 
00028   private:
00029 
00030     typedef std::vector<struct swig_type_info*> TypeFromLang;
00031 
00032     TypeFromLang types_;
00033 
00034 };
00035 
00036 
00037 template <class T>
00038 class TypeRegistry {
00039 
00040   public:
00041 
00042     static VirtualType& type () {
00043         return type_;
00044     }
00045 
00046   private:
00047 
00048     TypeRegistry () {}
00049 
00050     static VirtualType type_;
00051 
00052 };
00053 
00054 template <class T>
00055 VirtualType TypeRegistry<T>::type_;
00056 
00057 } /* namespace script */
00058 
00059 } /* namespace ugdk */
00060 
00061 template <class T>
00062 static void RegisterType(T* tp) {
00063     (void)tp;
00064 }
00065 
00066 template <typename T>
00067 T* GetNull () { return NULL; }
00068 
00069 #endif /* UGDK_SCRIPT_VIRTUALTYPE_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines