Medical Imaging Interaction Toolkit  2021.02.99-4e0dbe47
Medical Imaging Interaction Toolkit
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
#define MITKCORE_EXPORT
static const char * prefix()
Helper for VectorProperty to determine a good ITK ClassName.
DataCollection - Class to facilitate loading/accessing structured data.
VectorProperty< DATATYPE > Self
static const char * GetStaticNameOfClass()
const char * GetNameOfClass() const override
Abstract base class for properties.
#define MITK_DECLARE_VECTOR_PROPERTY(TYPE, PREFIX)
This should be used in .h files.
itk::SmartPointer< Self > Pointer
std::vector< DATATYPE > VectorType
Providing a std::vector as property.
itk::SmartPointer< const Self > ConstPointer
std::vector< std::string > GetClassHierarchy() const override