OpenLexocad  28.0
Type.h
Go to the documentation of this file.
1 #pragma once
2 #include <map>
3 #include <set>
4 #include <string>
5 #include <vector>
6 
7 
8 namespace Base
9 {
10 struct TypeData;
11 
12 
50 class LX_BASE_EXPORT Type
51 {
52 public:
54  Type(const Type& type);
55  Type(void);
57  virtual ~Type() = default;
58 
60  void* createInstance(void);
62  static void* createInstanceByName(const char* TypeName, bool bLoadModule = false);
63 
64  typedef void* (*instantiationMethod)(void);
65 
66  static Type fromName(const char* name);
67 
68  inline const Type getParent(void) const;
69  inline void getChildren(std::set<Type>& children) const;
70  inline void getAllChildren(std::set<Type>& children) const;
71  inline bool isDerivedFrom(const Type type) const;
72  inline bool isDerivedFrom(const std::vector<Base::Type>& types) const;
73 
75  static int getAllDerivedFrom(const Type type, std::vector<Type>& List);
76  static std::vector<Type> getAllDerivedFrom(const Type type);
78  static std::string getHierarchyAsString(Base::Type t);
79 
80  static int getNumTypes(void);
81 
82  static const Type createType(const Type parent, const char* name, instantiationMethod method = 0);
83 
84  unsigned int getKey(void) const;
85  bool isBad(void) const;
86  const std::string& getName(void) const;
87 
88  inline void operator=(const Type type);
89  inline bool operator==(const Type type) const;
90  inline bool operator!=(const Type type) const;
91 
92  inline bool operator<(const Type type) const;
93  inline bool operator<=(const Type type) const;
94  inline bool operator>=(const Type type) const;
95  inline bool operator>(const Type type) const;
96 
97  inline static const Type badType(void) { return Type(); }
98  static void init(void);
99 
100 protected:
101  static std::string getModuleName(const char* ClassName);
102 
103 
104 private:
105  unsigned int index;
106 
107  static std::map<std::string, unsigned int> typemap;
108  static std::vector<TypeData*> typedata;
109  static std::set<std::string> loadModuleSet;
110 
111  static std::vector<unsigned int> typeVector;
112  static std::map<unsigned int, unsigned int> typederivated;
113 };
114 
115 
116 inline unsigned int Type::getKey(void) const
117 {
118  return this->index;
119 }
120 
121 inline bool Type::operator!=(const Type type) const
122 {
123  return (this->getKey() != type.getKey());
124 }
125 
126 inline void Type::operator=(const Type type)
127 {
128  this->index = type.getKey();
129 }
130 
131 inline bool Type::operator==(const Type type) const
132 {
133  return (this->getKey() == type.getKey());
134 }
135 
136 inline bool Type::operator<(const Type type) const
137 {
138  return (this->getKey() < type.getKey());
139 }
140 
141 inline bool Type::operator<=(const Type type) const
142 {
143  return (this->getKey() <= type.getKey());
144 }
145 
146 inline bool Type::operator>=(const Type type) const
147 {
148  return (this->getKey() >= type.getKey());
149 }
150 
151 inline bool Type::operator>(const Type type) const
152 {
153  return (this->getKey() > type.getKey());
154 }
155 
156 inline bool Type::isBad(void) const
157 {
158  return (this->index == 0);
159 }
160 
161 
162 
163 } // namespace Base
Base::Type::getName
const std::string & getName(void) const
Base::Type
Definition: Type.h:51
Base::Type::operator==
bool operator==(const Type type) const
Definition: Type.h:131
Base::Type::getChildren
void getChildren(std::set< Type > &children) const
Base::Type::operator>=
bool operator>=(const Type type) const
Definition: Type.h:146
Base::Type::badType
static const Type badType(void)
Definition: Type.h:97
Base::Type::getAllDerivedFrom
static int getAllDerivedFrom(const Type type, std::vector< Type > &List)
Returns all types derived from type.
Base::Type::getParent
const Type getParent(void) const
Base::Type::getAllChildren
void getAllChildren(std::set< Type > &children) const
Base::Type::init
static void init(void)
Base::Type::getAllDerivedFrom
static std::vector< Type > getAllDerivedFrom(const Type type)
Base::Type::operator<=
bool operator<=(const Type type) const
Definition: Type.h:141
Base::Type::isDerivedFrom
bool isDerivedFrom(const Type type) const
Base::Type::createType
static const Type createType(const Type parent, const char *name, instantiationMethod method=0)
Base::Type::createInstanceByName
static void * createInstanceByName(const char *TypeName, bool bLoadModule=false)
creates a instance of the named type
Base::Type::getKey
unsigned int getKey(void) const
Definition: Type.h:116
Base::Type::isDerivedFrom
bool isDerivedFrom(const std::vector< Base::Type > &types) const
Base::Type::operator=
void operator=(const Type type)
Definition: Type.h:126
Base::Type::createInstance
void * createInstance(void)
creates a instance of this type
entt::operator!=
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
Base::Type::getHierarchyAsString
static std::string getHierarchyAsString(Base::Type t)
Returns the hierarchy of type t in backward order as a string.
Base::Type::getNumTypes
static int getNumTypes(void)
Base::Type::Type
Type(void)
Base::Type::~Type
virtual ~Type()=default
Destruction.
Base::Type::getModuleName
static std::string getModuleName(const char *ClassName)
Base::Type::fromName
static Type fromName(const char *name)
Base::Type::operator!=
bool operator!=(const Type type) const
Definition: Type.h:121
Base::Type::Type
Type(const Type &type)
Construction.
Base::Type::operator<
bool operator<(const Type type) const
Definition: Type.h:136
Base::Type::isBad
bool isBad(void) const
Definition: Type.h:156
Base
Definition: AbstractXMLReader.h:5
Base::Type::operator>
bool operator>(const Type type) const
Definition: Type.h:151