Medical Imaging Interaction Toolkit  2024.06.99-31d3c0df
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 
172  bool ToJSON(nlohmann::json& j) const override;
173 
179  bool FromJSON(const nlohmann::json& j) override;
180 
181  using BaseProperty::operator=;
182  EnumerationProperty & operator=(const EnumerationProperty &) = delete;
183 
184  protected:
189 
191 
192  bool IsEqual(const BaseProperty &property) const override;
193  bool Assign(const BaseProperty &property) override;
194 
196 
197  private:
198  IdType m_CurrentValue;
199  EnumIdsContainerType m_IdMap;
200  EnumStringsContainerType m_NameMap;
201  };
202 }
203 
204 #ifdef _MSC_VER
205 # pragma warning(pop)
206 #endif
207 
208 #endif
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:36
mitk::EnumerationProperty
Definition: mitkEnumerationProperty.h:43
mitk::FromJSON
MITKCORE_EXPORT void FromJSON(const nlohmann::json &j, AffineTransform3D::Pointer transform)
Read transform from JSON array (16 elements, resp. 4x4 matrix).
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
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
json
nlohmann::json json
Definition: mitkModelTestFixture.h:29
mitk::EnumerationProperty::IdType
unsigned int IdType
Definition: mitkEnumerationProperty.h:48
mitk::ToJSON
MITKCORE_EXPORT void ToJSON(nlohmann::json &j, AffineTransform3D::ConstPointer transform)
Write transform (4x4 matrix) as JSON array with 16 elements.
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