MetaEnum.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_MetaEnum_h__
21 #define __OpenKarto_MetaEnum_h__
22 
23 #include <OpenKarto/MetaType.h>
26 #include <OpenKarto/String.h>
27 #include <OpenKarto/Referenced.h>
28 #include <OpenKarto/List.h>
29 
30 namespace karto
31 {
32 
34 
35 
39 
43  struct EnumPair
44  {
50  kt_bool operator == (const EnumPair& rOther) const
51  {
52  return rOther.name == name && rOther.value == value;
53  }
54 
59 
64  };
65 
66 
71 
75 
76  struct FindByName
77  {
78  FindByName(const karto::String& rName)
79  : m_name(rName)
80  {
81 
82  }
83 
84  kt_bool operator()(const EnumPair& rOther) const
85  {
86  return rOther.name == m_name;
87  }
88 
90  };
91 
95 
96  struct FindByValue
97  {
99  : m_value(value)
100  {
101  }
102 
103  kt_bool operator()(const EnumPair& rOther) const
104  {
105  return rOther.value == m_value;
106  }
107 
109  };
110 
114 
115  struct MetaEnumPrivate;
116 
122  {
123  public:
129  template <typename T>
130  static MetaEnumHelper Register(const karto::String& rName)
131  {
132  MetaEnum& newEnum = MetaEnumManager::GetInstance().RegisterNew(rName, KartoTypeId<T>::Get(false));
133  return MetaEnumHelper(newEnum);
134  }
135 
136  public:
141  const karto::String& GetName() const;
142 
148  kt_bool HasName(const karto::String& rName) const;
149 
155  kt_bool HasValue(kt_int64s value) const;
156 
163  const karto::String& GetName(kt_int64s value) const;
164 
171  kt_int64s GetValue(const karto::String& rName) const;
172 
177  kt_size_t GetSize() const;
178 
185  const EnumPair& GetPair(kt_size_t index) const;
186 
187  public:
193  kt_bool operator==(const MetaEnum& rOther) const;
194 
200  kt_bool operator!=(const MetaEnum& rOther) const;
201 
202  protected:
207  void AddEnumPair(const EnumPair& rPair);
208 
209  private:
210  friend class MetaEnumHelper;
211  friend class MetaEnumManager;
212 
213  private:
214  MetaEnum(const karto::String& rName);
215  ~MetaEnum();
216 
217  private:
219  };
220 
222 
223 }
224 
225 #endif // __OpenKarto_MetaEnum_h__
bool kt_bool
Definition: Types.h:145
std::size_t kt_size_t
Definition: Types.h:138
kt_bool operator()(const EnumPair &rOther) const
Definition: MetaEnum.h:103
kt_int64s m_value
Definition: MetaEnum.h:108
#define KARTO_EXPORT
Definition: Macros.h:78
karto::String m_name
Definition: MetaEnum.h:89
List< EnumPair > EnumPairList
Definition: MetaEnum.h:70
FindByValue(kt_int64s value)
Definition: MetaEnum.h:98
karto::String name
Definition: MetaEnum.h:58
FindByName(const karto::String &rName)
Definition: MetaEnum.h:78
TFSIMD_FORCE_INLINE bool operator!=(const Vector3 &other) const
static MetaEnumHelper Register(const karto::String &rName)
Definition: MetaEnum.h:130
kt_bool operator==(const EnumPair &rOther) const
Definition: MetaEnum.h:50
kt_int64s value
Definition: MetaEnum.h:63
signed long long kt_int64s
Definition: Types.h:127
MetaEnumPrivate * m_pPrivate
Definition: MetaEnum.h:218
Definition: Any.cpp:20
kt_bool operator()(const EnumPair &rOther) const
Definition: MetaEnum.h:84


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