Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPropertyList.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 PROPERTYLIST_H_HEADER_INCLUDED_C1C77D8D
18 #define PROPERTYLIST_H_HEADER_INCLUDED_C1C77D8D
19 
20 #include "mitkBaseProperty.h"
21 #include "mitkGenericProperty.h"
22 #include "mitkUIDGenerator.h"
23 #include <MitkCoreExports.h>
24 
25 #include <itkObjectFactory.h>
26 
27 #include <map>
28 #include <string>
29 
30 namespace mitk
31 {
32  class XMLWriter;
33 
64  class MITKCORE_EXPORT PropertyList : public itk::Object
65  {
66  public:
68 
69 
72  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
73 
78  typedef std::map<std::string, BaseProperty::Pointer> PropertyMap;
80 
84  mitk::BaseProperty *GetProperty(const std::string &propertyKey) const;
85 
94  void SetProperty(const std::string &propertyKey, BaseProperty *property);
95 
104  void ReplaceProperty(const std::string &propertyKey, BaseProperty *property);
105 
109  void ConcatenatePropertyList(PropertyList *pList, bool replace = false);
110 
111  //##Documentation
112  //## @brief Convenience access method for GenericProperty<T> properties
113  //## (T being the type of the second parameter)
114  //## @return @a true property was found
115  template <typename T>
116  bool GetPropertyValue(const char *propertyKey, T &value) const
117  {
118  GenericProperty<T> *gp = dynamic_cast<GenericProperty<T> *>(GetProperty(propertyKey));
119  if (gp != nullptr)
120  {
121  value = gp->GetValue();
122  return true;
123  }
124  return false;
125  }
126 
130  bool GetBoolProperty(const char *propertyKey, bool &boolValue) const;
134  bool Get(const char *propertyKey, bool &boolValue) const;
135 
139  void SetBoolProperty(const char *propertyKey, bool boolValue);
143  void Set(const char *propertyKey, bool boolValue);
144 
148  bool GetIntProperty(const char *propertyKey, int &intValue) const;
152  bool Get(const char *propertyKey, int &intValue) const;
153 
157  void SetIntProperty(const char *propertyKey, int intValue);
161  void Set(const char *propertyKey, int intValue);
162 
166  bool GetFloatProperty(const char *propertyKey, float &floatValue) const;
170  bool Get(const char *propertyKey, float &floatValue) const;
171 
175  void SetFloatProperty(const char *propertyKey, float floatValue);
179  void Set(const char *propertyKey, float floatValue);
180 
184  bool GetDoubleProperty(const char *propertyKey, double &doubleValue) const;
188  bool Get(const char *propertyKey, double &doubleValue) const;
189 
193  void SetDoubleProperty(const char *propertyKey, double doubleValue);
197  void Set(const char *propertyKey, double doubleValue);
198 
202  bool GetStringProperty(const char *propertyKey, std::string &stringValue) const;
206  bool Get(const char *propertyKey, std::string &stringValue) const;
207 
211  void SetStringProperty(const char *propertyKey, const char *stringValue);
215  void Set(const char *propertyKey, const char *stringValue);
219  void Set(const char *propertyKey, const std::string &stringValue);
220 
225  virtual unsigned long GetMTime() const override;
226 
230  bool DeleteProperty(const std::string &propertyKey);
231 
232  const PropertyMap *GetMap() const { return &m_Properties; }
233  bool IsEmpty() const { return m_Properties.empty(); }
234  virtual void Clear();
235 
236  protected:
237  PropertyList();
238  PropertyList(const PropertyList &other);
239 
240  virtual ~PropertyList();
241 
246 
247  private:
248  virtual itk::LightObject::Pointer InternalClone() const override;
249  };
250 
251 } // namespace mitk
252 
253 #endif /* PROPERTYLIST_H_HEADER_INCLUDED_C1C77D8D */
bool IsEmpty() const
itk::SmartPointer< Self > Pointer
#define MITKCORE_EXPORT
signed integer value
Definition: jsoncpp.h:348
std::pair< std::string, BaseProperty::Pointer > PropertyMapElementType
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
Key-value list holding instances of BaseProperty.
Abstract base class for properties.
std::map< std::string, BaseProperty::Pointer > PropertyMap
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
PropertyMap m_Properties
Map of properties.
UTF-8 string value.
Definition: jsoncpp.h:351
static const char * replace[]
This is a dictionary to replace long names of classes, modules, etc. to shorter versions in the conso...
const PropertyMap * GetMap() const
virtual T GetValue() const