Medical Imaging Interaction Toolkit  2018.4.99-65942676
Medical Imaging Interaction Toolkit
mitkPropertyPersistenceInfo.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 mitkPropertyPersistenceInfo_h
14 #define mitkPropertyPersistenceInfo_h
15 
16 #include <functional>
17 
18 #include <mitkBaseProperty.h>
19 #include <mitkCommon.h>
20 
21 #include <MitkCoreExports.h>
22 #include <itkObjectFactory.h>
23 
24 namespace mitk
25 {
32  class MITKCORE_EXPORT PropertyPersistenceInfo : public itk::LightObject
33  {
34  public:
35  using DeserializationFunctionType = std::function<mitk::BaseProperty::Pointer(const std::string &)>;
36  using SerializationFunctionType = std::function<std::string(const mitk::BaseProperty *)>;
37  using MimeTypeNameType = std::string;
38 
40  itkFactorylessNewMacro(Self);
41  itkCloneMacro(Self) mitkNewMacro1Param(Self, const std::string &);
42  mitkNewMacro2Param(Self, const std::string &, const std::string &);
43 
44  std::string GetName() const;
45  std::string GetKey() const;
46  void SetName(const std::string &name);
47  void SetNameAndKey(const std::string &name, const std::string &key);
48 
49  bool IsRegEx() const;
50 
56  void UseRegEx(const std::string &nameRegEx, const std::string &nameTemplate);
57  void UseRegEx(const std::string &nameRegEx,
58  const std::string &nameTemplate,
59  const std::string &keyRegEx,
60  const std::string keyTemplate);
61 
62  const std::string &GetKeyTemplate() const;
63  const std::string &GetNameTemplate() const;
64 
65  const MimeTypeNameType &GetMimeTypeName() const;
66  void SetMimeTypeName(const MimeTypeNameType &mimeTypeName);
67 
68  const DeserializationFunctionType GetDeserializationFunction() const;
69  void SetDeserializationFunction(const DeserializationFunctionType &fnc);
70 
71  const SerializationFunctionType GetSerializationFunction() const;
72  void SetSerializationFunction(const SerializationFunctionType &fnc);
73 
74  PropertyPersistenceInfo::Pointer UnRegExByName(const std::string &propertyName) const;
75  PropertyPersistenceInfo::Pointer UnRegExByKey(const std::string &key) const;
76 
79  static MimeTypeNameType ANY_MIMETYPE_NAME();
80 
81  protected:
86  PropertyPersistenceInfo(const std::string &name = "");
87 
93  PropertyPersistenceInfo(const std::string &name, const std::string &mimeTypeName);
94 
95  ~PropertyPersistenceInfo() override;
96 
97  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
98 
99  private:
100  PropertyPersistenceInfo(const Self &other);
101  Self &operator=(const Self &other);
102 
103  struct Impl;
104  Impl *m_Impl;
105  };
106 
107  MITKCORE_EXPORT std::ostream &operator<<(std::ostream &os, const PropertyPersistenceInfo &info);
108 
109  namespace PropertyPersistenceSerialization
110  {
112  MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop);
113  }
114 
115  namespace PropertyPersistenceDeserialization
116  {
119  }
120 }
121 
122 #endif
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop)
DataCollection - Class to facilitate loading/accessing structured data.
#define mitkNewMacro2Param(classname, typea, typeb)
Definition: mitkCommon.h:85
Abstract base class for properties.
Property persistence info. This class is used to specify the way the persistance of a property of Bas...
std::function< mitk::BaseProperty::Pointer(const std::string &)> DeserializationFunctionType
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
MITKCORE_EXPORT std::ostream & operator<<(std::ostream &o, DataNode::Pointer &dtn)
MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeToStringProperty(const std::string &value)
std::function< std::string(const mitk::BaseProperty *)> SerializationFunctionType