OpenLexocad  27.1
Type.h
Go to the documentation of this file.
1 #ifndef __Type_H__
2 #define __Type_H__
3 
4 #include <map>
5 #include <set>
6 #include <string>
7 #include <vector>
8 
9 
10 namespace Base
11 {
12 struct TypeData;
13 
14 
52 class LX_BASE_EXPORT Type
53 {
54 public:
56  Type(const Type& type);
57  Type(void);
59  virtual ~Type();
60 
62  void* createInstance(void);
64  static void* createInstanceByName(const char* TypeName, bool bLoadModule = false);
65 
66  typedef void* (*instantiationMethod)(void);
67 
68  static Type fromName(const char* name);
69 
70  inline const Type getParent(void) const;
71  inline void getChildren(std::set<Type>& children) const;
72  inline void getAllChildren(std::set<Type>& children) const;
73  inline bool isDerivedFrom(const Type type) const;
74  inline bool isDerivedFrom(const std::vector<Base::Type>& types) const;
75 
77  static int getAllDerivedFrom(const Type type, std::vector<Type>& List);
78  static std::vector<Type> getAllDerivedFrom(const Type type);
80  static std::string getHierarchyAsString(Base::Type t);
81 
82  static int getNumTypes(void);
83 
84  static const Type createType(const Type parent, const char* name, instantiationMethod method = 0);
85 
86  unsigned int getKey(void) const;
87  bool isBad(void) const;
88  const std::string& getName(void) const;
89 
90  inline void operator=(const Type type);
91  inline bool operator==(const Type type) const;
92  inline bool operator!=(const Type type) const;
93 
94  inline bool operator<(const Type type) const;
95  inline bool operator<=(const Type type) const;
96  inline bool operator>=(const Type type) const;
97  inline bool operator>(const Type type) const;
98 
99  inline static const Type badType(void) { return Type(); }
100  static void init(void);
101 
102 protected:
103  static std::string getModuleName(const char* ClassName);
104 
105 
106 private:
107  unsigned int index;
108 
109  static std::map<std::string, unsigned int> typemap;
110  static std::vector<TypeData*> typedata;
111  static std::set<std::string> loadModuleSet;
112 
113  static std::vector<unsigned int> typeVector;
114  static std::map<unsigned int, unsigned int> typederivated;
115 };
116 
117 
118 inline unsigned int Type::getKey(void) const
119 {
120  return this->index;
121 }
122 
123 inline bool Type::operator!=(const Type type) const
124 {
125  return (this->getKey() != type.getKey());
126 }
127 
128 inline void Type::operator=(const Type type)
129 {
130  this->index = type.getKey();
131 }
132 
133 inline bool Type::operator==(const Type type) const
134 {
135  return (this->getKey() == 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::isBad(void) const
159 {
160  return (this->index == 0);
161 }
162 
163 
164 
165 } // namespace Base
166 
167 #endif // __FILETEMPLATE_H__
bool operator<=(const Type type) const
Definition: Type.h:143
bool operator>(const Type type) const
Definition: Type.h:153
bool operator>=(const Type type) const
Definition: Type.h:148
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:158
Core::PropertyText name
Definition: CoreDocument.h:167
Definition: Type.h:52
void operator=(const Type type)
Definition: Type.h:128
unsigned int getKey(void) const
Definition: Type.h:118
static const Type badType(void)
Definition: Type.h:99
Definition: AbstractXMLReader.h:5
bool operator<(const Type type) const
Definition: Type.h:138
bool operator==(const Type type) const
Definition: Type.h:133
bool operator!=(const Type type) const
Definition: Type.h:123