Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkEnumerationProperty.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkEnumerationProperty_h
14 #define mitkEnumerationProperty_h
15 
16 #include <mitkBaseProperty.h>
17 
18 #include <map>
19 #include <string>
20 
21 #ifdef _MSC_VER
22 # pragma warning(push)
23 # pragma warning(disable: 4522) // "multiple assignment operators specified"
24 #endif
25 
26 namespace mitk
27 {
44  {
45  public:
47  itkFactorylessNewMacro(Self);
48  itkCloneMacro(Self);
49 
53  typedef unsigned int IdType;
54 
58  typedef std::map<IdType, std::string> EnumIdsContainerType;
59 
63  typedef std::map<std::string, IdType> EnumStringsContainerType;
64 
68  typedef EnumIdsContainerType::const_iterator EnumConstIterator;
69 
80  virtual bool AddEnum(const std::string &name, const IdType &id);
81 
87  virtual bool SetValue(const std::string &name);
88 
94  virtual bool SetValue(const IdType &id);
95 
100  virtual IdType GetValueAsId() const;
101 
106  std::string GetValueAsString() const override;
107 
111  virtual void Clear();
112 
116  virtual EnumIdsContainerType::size_type Size() const;
117 
123  virtual EnumConstIterator Begin() const;
124 
129  virtual EnumConstIterator End() const;
130 
137  virtual std::string GetEnumString(const IdType &id) const;
138 
145  virtual IdType GetEnumId(const std::string &name) const;
146 
152  virtual bool IsValidEnumerationValue(const IdType &id) const;
153 
159  virtual bool IsValidEnumerationValue(const std::string &name) const;
160 
161  const EnumIdsContainerType &GetEnumIds() const;
162  const EnumStringsContainerType &GetEnumStrings() const;
163 
164  EnumIdsContainerType &GetEnumIds();
165  EnumStringsContainerType &GetEnumStrings();
166 
167  using BaseProperty::operator=;
168  EnumerationProperty & operator=(const EnumerationProperty &) = delete;
169 
170  protected:
175 
177 
178  bool IsEqual(const BaseProperty &property) const override;
179  bool Assign(const BaseProperty &property) override;
180 
182 
183  private:
184  IdType m_CurrentValue;
185 
186  typedef std::map<std::string, EnumIdsContainerType> IdMapForClassNameContainerType;
187  typedef std::map<std::string, EnumStringsContainerType> StringMapForClassNameContainerType;
188 
189  EnumIdsContainerType m_IdMap;
190  EnumStringsContainerType m_NameMap;
191  };
192 }
193 
194 #ifdef _MSC_VER
195 # pragma warning(pop)
196 #endif
197 
198 #endif
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:35
mitk::EnumerationProperty
Definition: mitkEnumerationProperty.h:43
mitk::EnumerationProperty::EnumConstIterator
EnumIdsContainerType::const_iterator EnumConstIterator
Definition: mitkEnumerationProperty.h:68
mitk::EnumerationProperty::EnumIdsContainerType
std::map< IdType, std::string > EnumIdsContainerType
Definition: mitkEnumerationProperty.h:58
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::EnumerationProperty::IdType
unsigned int IdType
Definition: mitkEnumerationProperty.h:48
mitkCloneMacro
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::EnumerationProperty::EnumStringsContainerType
std::map< std::string, IdType > EnumStringsContainerType
Definition: mitkEnumerationProperty.h:63
mitkBaseProperty.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15