Medical Imaging Interaction Toolkit  2022.10.99-efe2ad43
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 
72  itkFactorylessNewMacro(Self);
73  itkCloneMacro(Self);
74 
79  typedef std::map<std::string, BaseProperty::Pointer> PropertyMap;
80  typedef std::pair<std::string, BaseProperty::Pointer> PropertyMapElementType;
81 
82  // IPropertyProvider
83  BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) const override;
84  std::vector<std::string> GetPropertyKeys(const std::string &contextName = "", bool includeDefaultContext = false) const override;
85  std::vector<std::string> GetPropertyContextNames() const override;
86 
87  // IPropertyOwner
88  BaseProperty * GetNonConstProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = true) override;
89  void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
90  void RemoveProperty(const std::string &propertyKey, const std::string &contextName = "", bool fallBackOnDefaultContext = false) override;
91 
95  mitk::BaseProperty *GetProperty(const std::string &propertyKey) const;
96 
105  void ReplaceProperty(const std::string &propertyKey, BaseProperty *property);
106 
110  void ConcatenatePropertyList(PropertyList *pList, bool replace = false);
111 
112  //##Documentation
113  //## @brief Convenience access method for GenericProperty<T> properties
114  //## (T being the type of the second parameter)
115  //## @return @a true property was found
116  template <typename T>
117  bool GetPropertyValue(const char *propertyKey, T &value) const
118  {
119  GenericProperty<T> *gp = dynamic_cast<GenericProperty<T> *>(GetProperty(propertyKey));
120  if (gp != nullptr)
121  {
122  value = gp->GetValue();
123  return true;
124  }
125  return false;
126  }
127 
131  bool GetBoolProperty(const char *propertyKey, bool &boolValue) const;
135  bool Get(const char *propertyKey, bool &boolValue) const;
136 
140  void SetBoolProperty(const char *propertyKey, bool boolValue);
144  void Set(const char *propertyKey, bool boolValue);
145 
149  bool GetIntProperty(const char *propertyKey, int &intValue) const;
153  bool Get(const char *propertyKey, int &intValue) const;
154 
158  void SetIntProperty(const char *propertyKey, int intValue);
162  void Set(const char *propertyKey, int intValue);
163 
167  bool GetFloatProperty(const char *propertyKey, float &floatValue) const;
171  bool Get(const char *propertyKey, float &floatValue) const;
172 
176  void SetFloatProperty(const char *propertyKey, float floatValue);
180  void Set(const char *propertyKey, float floatValue);
181 
185  bool GetDoubleProperty(const char *propertyKey, double &doubleValue) const;
189  bool Get(const char *propertyKey, double &doubleValue) const;
190 
194  void SetDoubleProperty(const char *propertyKey, double doubleValue);
198  void Set(const char *propertyKey, double doubleValue);
199 
203  bool GetStringProperty(const char *propertyKey, std::string &stringValue) const;
207  bool Get(const char *propertyKey, std::string &stringValue) const;
208 
212  void SetStringProperty(const char *propertyKey, const char *stringValue);
216  void Set(const char *propertyKey, const char *stringValue);
220  void Set(const char *propertyKey, const std::string &stringValue);
221 
226  itk::ModifiedTimeType GetMTime() const override;
227 
231  bool DeleteProperty(const std::string &propertyKey);
232 
233  const PropertyMap *GetMap() const { return &m_Properties; }
234  bool IsEmpty() const { return m_Properties.empty(); }
235  virtual void Clear();
236 
237  protected:
238  PropertyList();
239  PropertyList(const PropertyList &other);
240 
241  ~PropertyList() override;
242 
247 
248  private:
249  itk::LightObject::Pointer InternalClone() const override;
250  };
251 
252 } // namespace mitk
253 
254 #endif /* PROPERTYLIST_H_HEADER_INCLUDED_C1C77D8D */
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:35
mitk::GenericProperty::GetValue
virtual T GetValue() const
mitkGenericProperty.h
mitkUIDGenerator.h
itk::SmartPointer< const Self >
mitk::GenericProperty
Definition: mitkGenericProperty.h:45
mitk::PropertyList::GetPropertyValue
bool GetPropertyValue(const char *propertyKey, T &value) const
Convenience access method for GenericProperty<T> properties (T being the type of the second parameter...
Definition: mitkPropertyList.h:117
mitk::PropertyList::IsEmpty
bool IsEmpty() const
Definition: mitkPropertyList.h:234
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::PropertyList::GetMap
const PropertyMap * GetMap() const
Definition: mitkPropertyList.h:233
mitkIPropertyOwner.h
MitkCoreExports.h
mitk::PropertyList::PropertyMap
std::map< std::string, BaseProperty::Pointer > PropertyMap
Definition: mitkPropertyList.h:73
mitk::PropertyList
Key-value list holding instances of BaseProperty.
Definition: mitkPropertyList.h:64
mbilog::replace
static const char * replace[]
This is a dictionary to replace long names of classes, modules, etc. to shorter versions in the conso...
Definition: mbilogTextDictionary.h:20
mitk::PropertyList::m_Properties
PropertyMap m_Properties
Map of properties.
Definition: mitkPropertyList.h:246
mitk::MitkMultilabelIOMimeTypes::Get
MITKMULTILABELIO_EXPORT std::vector< CustomMimeType * > Get()
mitk::IPropertyOwner
Definition: mitkIPropertyOwner.h:22
mitkBaseProperty.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::PropertyList::PropertyMapElementType
std::pair< std::string, BaseProperty::Pointer > PropertyMapElementType
Definition: mitkPropertyList.h:80