Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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 (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 PROPERTYLIST_H_HEADER_INCLUDED_C1C77D8D
14 #define PROPERTYLIST_H_HEADER_INCLUDED_C1C77D8D
15 
16 #include "mitkBaseProperty.h"
17 #include "mitkGenericProperty.h"
18 #include "mitkUIDGenerator.h"
19 #include "mitkIPropertyOwner.h"
20 #include <MitkCoreExports.h>
21 
22 #include <itkObjectFactory.h>
23 
24 #include <map>
25 #include <string>
26 
27 namespace mitk
28 {
29  class XMLWriter;
30 
64  class MITKCORE_EXPORT PropertyList : public itk::Object, public IPropertyOwner
65  {
66  public:
68 
69 
72  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
73 
74 
78  typedef std::map<std::string, BaseProperty::Pointer> PropertyMap;
80 
81  // IPropertyProvider
82  BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) const override;
83  std::vector<std::string> GetPropertyKeys(const std::string &contextName = "", bool includeDefaultContext = false) const override;
84  std::vector<std::string> GetPropertyContextNames() const override;
85 
86  // IPropertyOwner
87  BaseProperty * GetNonConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) override;
88  void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
89  void RemoveProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
90 
94  mitk::BaseProperty *GetProperty(const std::string &propertyKey) const;
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  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  ~PropertyList() override;
241 
246 
247  private:
248  itk::LightObject::Pointer InternalClone() const override;
249  };
250 
251 } // namespace mitk
252 
253 #endif /* PROPERTYLIST_H_HEADER_INCLUDED_C1C77D8D */
#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.
virtual T GetValue() const
Abstract base class for properties.
std::map< std::string, BaseProperty::Pointer > PropertyMap
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
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