Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkVectorProperty.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 mitkVectorProperty_h
14 #define mitkVectorProperty_h
15 
16 // MITK
17 #include <MitkCoreExports.h>
18 #include <mitkBaseProperty.h>
19 
20 // STL
21 #include <vector>
22 
23 namespace mitk
24 {
31  template <typename D>
33  {
34  static const char *prefix() { return "Invalid"; }
35  };
36 
51  template <typename DATATYPE>
53  {
54  public:
55  typedef std::vector<DATATYPE> VectorType;
56 
57  // Manually expand most of mitkClassMacro:
58  // mitkClassMacro(VectorProperty<DATATYPE>, mitk::BaseProperty);
59  // This manual expansion is done to override explicitly
60  // the GetNameOfClass() and GetStaticNameOfClass() methods
65  std::vector<std::string> GetClassHierarchy() const override { return mitk::GetClassHierarchy<Self>(); }
69  static const char *GetStaticNameOfClass()
70  {
71  // concatenate a prefix dependent on the template type and our own classname
72  static std::string nameOfClass = std::string(VectorPropertyDataType<DATATYPE>::prefix()) + "VectorProperty";
73  return nameOfClass.c_str();
74  }
75 
76  const char *GetNameOfClass() const override { return this->GetStaticNameOfClass(); }
77  itkFactorylessNewMacro(Self);
78  itkCloneMacro(Self);
79 
88  std::string GetValueAsString() const override;
89 
91  virtual const VectorType &GetValue() const;
92 
94  virtual void SetValue(const VectorType &parameter_vector);
95 
96  private:
98  VectorProperty &operator=(const Self &);
99 
101  itk::LightObject::Pointer InternalClone() const override;
102 
104  bool IsEqual(const BaseProperty &an_other_property) const override;
105 
107  bool Assign(const BaseProperty &an_other_property) override;
108 
110  VectorType m_PropertyContent;
111  };
112 
114 #define MITK_DECLARE_VECTOR_PROPERTY(TYPE, PREFIX) \
115  \
116  typedef VectorProperty<TYPE> PREFIX##VectorProperty; \
117  \
118  template <> \
119  \
120  struct VectorPropertyDataType<TYPE> \
121  { \
122  static const char *prefix() { return #PREFIX; } \
123  };
124 
126 #define MITK_DEFINE_VECTOR_PROPERTY(TYPE) template class VectorProperty<TYPE>;
127 
130 
131 } // namespace
132 
133 #endif
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:35
mitk::VectorProperty::Self
VectorProperty< DATATYPE > Self
Definition: mitkVectorProperty.h:61
itk::SmartPointer< Self >
mitk::VectorProperty::GetNameOfClass
const char * GetNameOfClass() const override
Definition: mitkVectorProperty.h:76
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::VectorPropertyDataType::prefix
static const char * prefix()
Definition: mitkVectorProperty.h:34
mitk::VectorPropertyDataType
Helper for VectorProperty to determine a good ITK ClassName.
Definition: mitkVectorProperty.h:32
mitk::VectorProperty::SuperClass
BaseProperty SuperClass
Definition: mitkVectorProperty.h:62
MitkCoreExports.h
MITK_DECLARE_VECTOR_PROPERTY
#define MITK_DECLARE_VECTOR_PROPERTY(TYPE, PREFIX)
This should be used in .h files.
Definition: mitkVectorProperty.h:114
mitk::VectorProperty
Providing a std::vector as property.
Definition: mitkVectorProperty.h:52
mitk::VectorProperty::GetStaticNameOfClass
static const char * GetStaticNameOfClass()
Definition: mitkVectorProperty.h:69
mitk::VectorProperty::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkVectorProperty.h:63
mitk::VectorProperty::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: mitkVectorProperty.h:64
mitk::VectorProperty::GetClassHierarchy
std::vector< std::string > GetClassHierarchy() const override
Definition: mitkVectorProperty.h:65
mitkBaseProperty.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::VectorProperty::VectorType
std::vector< DATATYPE > VectorType
Definition: mitkVectorProperty.h:55