OpenLexocad  27.0
Type.h
Go to the documentation of this file.
1 #ifndef __Type_H__
2 #define __Type_H__
3 
4 // Std. configurations
5 #pragma warning(disable : 4251)
6 #include <Base/base_defines.h>
7 
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
12 
13 
14 namespace Base
15 {
16 struct TypeData;
17 
18 
57 {
58 public:
60  Type(const Type& type);
61  Type(void);
63  virtual ~Type();
64 
66  void* createInstance(void);
68  static void* createInstanceByName(const char* TypeName, bool bLoadModule = false);
69 
70  typedef void* (*instantiationMethod)(void);
71 
72  static Type fromName(const char* name);
73 
74  inline const Type getParent(void) const;
75  inline void getChildren(std::set<Type>& children) const;
76  inline void getAllChildren(std::set<Type>& children) const;
77  inline bool isDerivedFrom(const Type type) const;
78  inline bool isDerivedFrom(const std::vector<Base::Type>& types) const;
79 
81  static int getAllDerivedFrom(const Type type, std::vector<Type>& List);
82  static std::vector<Type> getAllDerivedFrom(const Type type);
84  static std::string getHierarchyAsString(Base::Type t);
85 
86  static int getNumTypes(void);
87 
88  static const Type createType(const Type parent, const char* name, instantiationMethod method = 0);
89 
90  unsigned int getKey(void) const;
91  bool isBad(void) const;
92  const std::string& getName(void) const;
93 
94  inline void operator=(const Type type);
95  inline bool operator==(const Type type) const;
96  inline bool operator!=(const Type type) const;
97 
98  inline bool operator<(const Type type) const;
99  inline bool operator<=(const Type type) const;
100  inline bool operator>=(const Type type) const;
101  inline bool operator>(const Type type) const;
102 
103  inline static const Type badType(void) { return Type(); }
104  static void init(void);
105 
106 protected:
107  static std::string getModuleName(const char* ClassName);
108 
109 
110 private:
111  unsigned int index;
112 
113 #pragma warning(disable : 4251)
114  static std::map<std::string, unsigned int> typemap;
115  static std::vector<TypeData*> typedata;
116  static std::set<std::string> loadModuleSet;
117 
118  static std::vector<unsigned int> typeVector;
119  static std::map<unsigned int, unsigned int> typederivated;
120 };
121 
122 
123 inline unsigned int Type::getKey(void) const
124 {
125  return this->index;
126 }
127 
128 inline bool Type::operator!=(const Type type) const
129 {
130  return (this->getKey() != type.getKey());
131 }
132 
133 inline void Type::operator=(const Type type)
134 {
135  this->index = type.getKey();
136 }
137 
138 inline bool Type::operator==(const Type type) const
139 {
140  return (this->getKey() == type.getKey());
141 }
142 
143 inline bool Type::operator<(const Type type) const
144 {
145  return (this->getKey() < type.getKey());
146 }
147 
148 inline bool Type::operator<=(const Type type) const
149 {
150  return (this->getKey() <= type.getKey());
151 }
152 
153 inline bool Type::operator>=(const Type type) const
154 {
155  return (this->getKey() >= type.getKey());
156 }
157 
158 inline bool Type::operator>(const Type type) const
159 {
160  return (this->getKey() > type.getKey());
161 }
162 
163 inline bool Type::isBad(void) const
164 {
165  return (this->index == 0);
166 }
167 
168 
169 
170 } // namespace Base
171 
172 #endif // __FILETEMPLATE_H__
bool operator<=(const Type type) const
Definition: Type.h:148
bool operator>(const Type type) const
Definition: Type.h:158
bool operator>=(const Type type) const
Definition: Type.h:153
#define BASE_EXPORT
Definition: base_defines.h:12
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) ENTT_NOEXCEPT
Compares two hashed strings.
Definition: entt.hpp:570
bool isBad(void) const
Definition: Type.h:163
Core::PropertyText name
Definition: CoreDocument.h:143
Definition: Type.h:56
void operator=(const Type type)
Definition: Type.h:133
unsigned int getKey(void) const
Definition: Type.h:123
static const Type badType(void)
Definition: Type.h:103
Definition: AbstractXMLReader.h:8
bool operator<(const Type type) const
Definition: Type.h:143
bool operator==(const Type type) const
Definition: Type.h:138
bool operator!=(const Type type) const
Definition: Type.h:128