Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
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
mitk::PropertyPersistenceSerialization::serializeByGetValueAsString
MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop)
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:36
mitkNewMacro2Param
#define mitkNewMacro2Param(classname, typea, typeb)
Definition: mitkCommon.h:81
mitk::PropertyPersistenceInfo::DeserializationFunctionType
std::function< mitk::BaseProperty::Pointer(const std::string &)> DeserializationFunctionType
Definition: mitkPropertyPersistenceInfo.h:37
mitk::BaseProperty::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkBaseProperty.h:39
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::operator<<
MITKCORE_EXPORT std::ostream & operator<<(std::ostream &o, DataNode::Pointer &dtn)
itk::SmartPointer< Self >
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::PropertyPersistenceInfo::SerializationFunctionType
std::function< std::string(const mitk::BaseProperty *)> SerializationFunctionType
Definition: mitkPropertyPersistenceInfo.h:38
MitkCoreExports.h
mitkCommon.h
mitk::PropertyPersistenceInfo::MimeTypeNameType
std::string MimeTypeNameType
Definition: mitkPropertyPersistenceInfo.h:39
mitk::PropertyPersistenceInfo
Property persistence info. This class is used to specify the way the persistance of a property of Bas...
Definition: mitkPropertyPersistenceInfo.h:32
mitk::PropertyPersistenceDeserialization::deserializeToStringProperty
MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeToStringProperty(const std::string &value)
mitkBaseProperty.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15