Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkSmartPointerProperty.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 MITKSMARTPOINTERPROPERTY_H_HEADER_INCLUDED_C126B791
18 #define MITKSMARTPOINTERPROPERTY_H_HEADER_INCLUDED_C126B791
19 
20 #include "mitkBaseProperty.h"
21 #include "mitkUIDGenerator.h"
22 #include <MitkCoreExports.h>
23 
24 #include <list>
25 #include <map>
26 #include <string>
27 
28 namespace mitk
29 {
30 #ifdef _MSC_VER
31 #pragma warning(push)
32 #pragma warning(disable : 4522)
33 #endif
34 
35  //##Documentation
36  //## @brief Property containing a smart-pointer
37  //## @ingroup DataManagement
39  {
40  public:
42 
43  itkFactorylessNewMacro(Self) itkCloneMacro(Self) mitkNewMacro1Param(SmartPointerProperty, itk::Object *);
44 
45  typedef itk::Object::Pointer ValueType;
46 
47  itk::Object::Pointer GetSmartPointer() const;
48  ValueType GetValue() const;
49 
50  void SetSmartPointer(itk::Object *);
51  void SetValue(const ValueType &);
52 
54  virtual std::string GetValueAsString() const override;
55 
56  static void PostProcessXMLReading();
57 
59  static unsigned int GetReferenceCountFor(itk::Object *);
60  static std::string GetReferenceUIDFor(itk::Object *);
61  static void RegisterPointerTarget(itk::Object *, const std::string uid);
62 
63  using BaseProperty::operator=;
64 
65  protected:
66  SmartPointerProperty(itk::Object * = nullptr);
67  SmartPointerProperty(const SmartPointerProperty &);
68 
69  itk::Object::Pointer m_SmartPointer;
70 
71  private:
72  // purposely not implemented
73  SmartPointerProperty &operator=(const SmartPointerProperty &);
74 
75  itk::LightObject::Pointer InternalClone() const override;
76 
77  virtual bool IsEqual(const BaseProperty &) const override;
78  virtual bool Assign(const BaseProperty &) override;
79 
80  typedef std::map<itk::Object *, unsigned int> ReferenceCountMapType;
81  typedef std::map<itk::Object *, std::string> ReferencesUIDMapType;
82  typedef std::map<SmartPointerProperty *, std::string> ReadInSmartPointersMapType;
83  typedef std::map<std::string, itk::Object *> ReadInTargetsMapType;
84 
86  static ReferenceCountMapType m_ReferenceCount;
87  static ReferencesUIDMapType m_ReferencesUID;
88  static ReadInSmartPointersMapType m_ReadInInstances;
89  static ReadInTargetsMapType m_ReadInTargets;
90 
92  static UIDGenerator m_UIDGenerator;
93  };
94 
95 #ifdef _MSC_VER
96 #pragma warning(pop)
97 #endif
98 
99 } // namespace mitk
100 
101 #endif /* MITKSMARTPOINTERPROPERTY_H_HEADER_INCLUDED_C126B791 */
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:76
Generated unique IDs.
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
Property containing a smart-pointer.
Abstract base class for properties.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44