Medical Imaging Interaction Toolkit  2022.04.99-8b707dbd
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:
37  using DeserializationFunctionType = std::function<mitk::BaseProperty::Pointer(const std::string &)>;
38  using SerializationFunctionType = std::function<std::string(const mitk::BaseProperty *)>;
39  using MimeTypeNameType = std::string;
40 
42  itkFactorylessNewMacro(Self);
43  itkCloneMacro(Self) mitkNewMacro1Param(Self, const std::string &);
44  mitkNewMacro2Param(Self, const std::string &, const std::string &);
45 
46  std::string GetName() const;
47  std::string GetKey() const;
48  void SetName(const std::string &name);
49  void SetNameAndKey(const std::string &name, const std::string &key);
50 
51  bool IsRegEx() const;
52 
58  void UseRegEx(const std::string &nameRegEx, const std::string &nameTemplate);
59  void UseRegEx(const std::string &nameRegEx,
60  const std::string &nameTemplate,
61  const std::string &keyRegEx,
62  const std::string keyTemplate);
63 
64  const std::string &GetKeyTemplate() const;
65  const std::string &GetNameTemplate() const;
66 
67  const MimeTypeNameType &GetMimeTypeName() const;
68  void SetMimeTypeName(const MimeTypeNameType &mimeTypeName);
69 
70  const DeserializationFunctionType GetDeserializationFunction() const;
71  void SetDeserializationFunction(const DeserializationFunctionType &fnc);
72 
73  const SerializationFunctionType GetSerializationFunction() const;
74  void SetSerializationFunction(const SerializationFunctionType &fnc);
75 
76  PropertyPersistenceInfo::Pointer UnRegExByName(const std::string &propertyName) const;
77  PropertyPersistenceInfo::Pointer UnRegExByKey(const std::string &key) const;
78 
81  static MimeTypeNameType ANY_MIMETYPE_NAME();
82 
83  protected:
88  PropertyPersistenceInfo(const std::string &name = "");
89 
95  PropertyPersistenceInfo(const std::string &name, const std::string &mimeTypeName);
96 
97  ~PropertyPersistenceInfo() override;
98 
99  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
100 
101  private:
102  PropertyPersistenceInfo(const Self &other);
103  Self &operator=(const Self &other);
104 
105  struct Impl;
106  Impl *m_Impl;
107  };
108 
109  MITKCORE_EXPORT std::ostream &operator<<(std::ostream &os, const PropertyPersistenceInfo &info);
110 
111  namespace PropertyPersistenceSerialization
112  {
114  MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop);
115  }
116 
117  namespace PropertyPersistenceDeserialization
118  {
121  }
122 }
123 
124 #endif
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
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:81
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:45
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