Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef mitkPropertyPersistenceInfo_h
18 #define mitkPropertyPersistenceInfo_h
19 
20 #include <functional>
21 
22 #include <mitkBaseProperty.h>
23 #include <mitkCommon.h>
24 
25 #include <MitkCoreExports.h>
26 #include <itkObjectFactory.h>
27 
28 namespace mitk
29 {
36  class MITKCORE_EXPORT PropertyPersistenceInfo : public itk::LightObject
37  {
38  public:
39  using DeserializationFunctionType = std::function<mitk::BaseProperty::Pointer(const std::string &)>;
40  using SerializationFunctionType = std::function<std::string(const mitk::BaseProperty *)>;
41  using MimeTypeNameType = std::string;
42 
44  itkFactorylessNewMacro(Self) itkCloneMacro(Self) mitkNewMacro1Param(Self, const std::string &);
45  mitkNewMacro2Param(Self, const std::string &, const std::string &);
46 
47  std::string GetName() const;
48  std::string GetKey() const;
49  void SetName(const std::string &name);
50  void SetNameAndKey(const std::string &name, const std::string &key);
51 
52  bool IsRegEx() const;
53 
59  void UseRegEx(const std::string &nameRegEx, const std::string &nameTemplate);
60  void UseRegEx(const std::string &nameRegEx,
61  const std::string &nameTemplate,
62  const std::string &keyRegEx,
63  const std::string keyTemplate);
64 
65  const std::string &GetKeyTemplate() const;
66  const std::string &GetNameTemplate() const;
67 
68  const MimeTypeNameType &GetMimeTypeName() const;
69  void SetMimeTypeName(const MimeTypeNameType &mimeTypeName);
70 
71  const DeserializationFunctionType GetDeserializationFunction() const;
72  void SetDeserializationFunction(const DeserializationFunctionType &fnc);
73 
74  const SerializationFunctionType GetSerializationFunction() const;
75  void SetSerializationFunction(const SerializationFunctionType &fnc);
76 
77  PropertyPersistenceInfo::Pointer UnRegExByName(const std::string &propertyName) const;
78  PropertyPersistenceInfo::Pointer UnRegExByKey(const std::string &key) const;
79 
82  static MimeTypeNameType ANY_MIMETYPE_NAME();
83 
84  protected:
89  PropertyPersistenceInfo(const std::string &name = "");
90 
96  PropertyPersistenceInfo(const std::string &name, const std::string &mimeTypeName);
97 
98  virtual ~PropertyPersistenceInfo();
99 
100  virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override;
101 
102  private:
103  PropertyPersistenceInfo(const Self &other);
104  Self &operator=(const Self &other);
105 
106  struct Impl;
107  Impl *m_Impl;
108  };
109 
110  MITKCORE_EXPORT std::ostream &operator<<(std::ostream &os, const PropertyPersistenceInfo &info);
111 
112  namespace PropertyPersistenceSerialization
113  {
115  MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop);
116  }
117 
118  namespace PropertyPersistenceDeserialization
119  {
122  }
123 }
124 
125 #endif
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:76
MITKCORE_EXPORT::std::string serializeByGetValueAsString(const mitk::BaseProperty *prop)
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
MITKCORE_EXPORT mitk::BaseProperty::Pointer deserializeToStringProperty(const std::string &value)
#define mitkNewMacro2Param(classname, typea, typeb)
Definition: mitkCommon.h:89
static void info(const char *fmt,...)
Definition: svm.cpp:100
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:53
static std::string GetName(std::string fileName, std::string suffix)
std::function< std::string(const mitk::BaseProperty *)> SerializationFunctionType