Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _MITK_ENUMERATION_PROPERTY__H_
18 #define _MITK_ENUMERATION_PROPERTY__H_
19 
20 #include "mitkBaseProperty.h"
21 #include <map>
22 #include <string>
23 
24 namespace mitk
25 {
26 #ifdef _MSC_VER
27 #pragma warning(push)
28 #pragma warning(disable : 4522)
29 #endif
30 
53  {
54  public:
56 
57  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
58 
62  typedef unsigned int IdType;
63 
68  typedef std::map<IdType, std::string> EnumIdsContainerType;
69 
74  typedef std::map<std::string, IdType> EnumStringsContainerType;
75 
79  typedef EnumIdsContainerType::const_iterator EnumConstIterator;
80 
91  virtual bool AddEnum(const std::string &name, const IdType &id);
92 
99  virtual bool SetValue(const std::string &name);
100 
107  virtual bool SetValue(const IdType &id);
108 
113  virtual IdType GetValueAsId() const;
114 
119  virtual std::string GetValueAsString() const override;
120 
124  virtual void Clear();
125 
132  virtual EnumIdsContainerType::size_type Size() const;
133 
139  virtual EnumConstIterator Begin() const;
140 
146  virtual EnumConstIterator End() const;
147 
154  virtual std::string GetEnumString(const IdType &id) const;
155 
162  virtual IdType GetEnumId(const std::string &name) const;
163 
170  virtual bool IsValidEnumerationValue(const IdType &val) const;
171 
178  virtual bool IsValidEnumerationValue(const std::string &val) const;
179 
180  const EnumIdsContainerType &GetEnumIds() const;
181  const EnumStringsContainerType &GetEnumStrings() const;
182 
183  EnumIdsContainerType &GetEnumIds();
184  EnumStringsContainerType &GetEnumStrings();
185 
186  using BaseProperty::operator=;
187 
188  protected:
193 
194  EnumerationProperty(const EnumerationProperty &);
195 
196  virtual bool IsEqual(const BaseProperty &property) const override;
197  virtual bool Assign(const BaseProperty &property) override;
198 
199  itk::LightObject::Pointer InternalClone() const override;
200 
201  private:
202  // purposely not implemented
203  EnumerationProperty &operator=(const EnumerationProperty &);
204  IdType m_CurrentValue;
205 
206  typedef std::map<std::string, EnumIdsContainerType> IdMapForClassNameContainerType;
207  typedef std::map<std::string, EnumStringsContainerType> StringMapForClassNameContainerType;
208 
209  static IdMapForClassNameContainerType s_IdMapForClassName;
210  static StringMapForClassNameContainerType s_StringMapForClassName;
211  };
212 
213 #ifdef _MSC_VER
214 #pragma warning(pop)
215 #endif
216 
217 } // namespace
218 
219 #endif
#define MITKCORE_EXPORT
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
Abstract base class for properties.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
EnumIdsContainerType::const_iterator EnumConstIterator
std::map< IdType, std::string > EnumIdsContainerType
std::map< std::string, IdType > EnumStringsContainerType