Meta.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011, SRI International (R)
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #ifndef __OpenKarto_Meta_h__
21 #define __OpenKarto_Meta_h__
22 
23 #include <OpenKarto/MetaType.h>
24 #include <OpenKarto/MetaClass.h>
26 #include <OpenKarto/MetaEnum.h>
28 
29 namespace karto
30 {
31 
33 
34 
38 
44  {
45  return MetaClassManager::GetInstance().GetSize();
46  }
47 
55  {
56  return MetaClassManager::GetInstance()[index];
57  }
58 
65  inline const MetaClass& GetMetaClassByName(const karto::String& rName)
66  {
67  return MetaClassManager::GetInstance().GetByName(rName);
68  }
69 
76  template <typename T>
77  const MetaClass& GetMetaClassByObject(const T& rObject)
78  {
79  return MetaClassManager::GetInstance().GetById(GetTypeId(rObject));
80  }
81 
87  template <typename T>
89  {
90  return MetaClassManager::GetInstance().GetById(GetTypeId<T>());
91  }
92 
96 
102  {
103  return MetaEnumManager::GetInstance().GetSize();
104  }
105 
112  inline const MetaEnum& GetMetaEnumByIndex(kt_size_t index)
113  {
114  return MetaEnumManager::GetInstance()[index];
115  }
116 
123  inline const MetaEnum& GetMetaEnumByName(const karto::String& rName)
124  {
125  return MetaEnumManager::GetInstance().GetByName(rName);
126  }
127 
134  template <typename T>
135  const MetaEnum& GetMetaEnumByObject(const T& rObject)
136  {
137  return MetaEnumManager::GetInstance().GetById(GetTypeId<T>(rObject));
138  }
139 
145  template <typename T>
147  {
148  return MetaEnumManager::GetInstance().GetById(GetTypeId<T>());
149  }
150 
154 
155  //@cond EXCLUDE
160  KARTO_EXPORT void CheckTypeRegistered(const char* pName, void (*registerFunc)());
161  // @endcond
162 
166 
170  #define KARTO_TYPE(type) \
171  template <> struct KartoTypeId<type> \
172  { \
173  static const char* Get(kt_bool = true) {return #type;} \
174  }; \
175 
176 
180  #define KARTO_AUTO_TYPE(type, registerFunc) \
181  template <> struct KartoTypeId<type> \
182  { \
183  static const char* Get(kt_bool checkRegister = true) \
184  { \
185  if (checkRegister) \
186  CheckTypeRegistered(#type, registerFunc); \
187  return #type; \
188  } \
189  }; \
190 
191 
198  #define KARTO_RTTI() \
199  public: virtual const char* GetKartoClassId() const {return GetKartoTypeIdTemplate(this);} \
200  private:
201 
203 
204 }
205 
206 #endif // __OpenKarto_Meta_h__
std::size_t kt_size_t
Definition: Types.h:138
const MetaClass & GetMetaClassByIndex(kt_size_t index)
Definition: Meta.h:54
const MetaEnum & GetMetaEnumByType()
Definition: Meta.h:146
#define KARTO_EXPORT
Definition: Macros.h:78
const MetaEnum & GetMetaEnumByIndex(kt_size_t index)
Definition: Meta.h:112
kt_size_t GetRegisteredMetaEnumSize()
Definition: Meta.h:101
const MetaClass & GetMetaClassByName(const karto::String &rName)
Definition: Meta.h:65
const MetaEnum & GetMetaEnumByObject(const T &rObject)
Definition: Meta.h:135
const MetaEnum & GetMetaEnumByName(const karto::String &rName)
Definition: Meta.h:123
const MetaClass & GetMetaClassByType()
Definition: Meta.h:88
Definition: Any.cpp:20
void CheckTypeRegistered(const char *pName, void(*registerFunc)())
Definition: Meta.cpp:24
kt_size_t GetRegisteredMetaClassSize()
Definition: Meta.h:43
const MetaClass & GetMetaClassByObject(const T &rObject)
Definition: Meta.h:77


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Tue Nov 7 2017 06:02:36