Medical Imaging Interaction Toolkit  2016.11.0
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,
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 mitkVectorProperty_h
18 #define mitkVectorProperty_h
19 
20 // MITK
21 #include <MitkCoreExports.h>
22 #include <mitkBaseProperty.h>
23 
24 // STL
25 #include <vector>
26 
27 namespace mitk
28 {
35  template <typename D>
37  {
38  static const char *prefix() { return "Invalid"; }
39  };
40 
55  template <typename DATATYPE>
57  {
58  public:
59  typedef std::vector<DATATYPE> VectorType;
60 
61  // Manually expand most of mitkClassMacro:
62  // mitkClassMacro(VectorProperty<DATATYPE>, mitk::BaseProperty);
63  // This manual expansion is done to override explicitly
64  // the GetNameOfClass() and GetStaticNameOfClass() methods
69  virtual std::vector<std::string> GetClassHierarchy() const override { return mitk::GetClassHierarchy<Self>(); }
73  static const char *GetStaticNameOfClass()
74  {
75  // concatenate a prefix dependent on the template type and our own classname
76  static std::string nameOfClass = std::string(VectorPropertyDataType<DATATYPE>::prefix()) + "VectorProperty";
77  return nameOfClass.c_str();
78  }
79 
80  virtual const char *GetNameOfClass() const override { return this->GetStaticNameOfClass(); }
81  itkFactorylessNewMacro(Self);
82  itkCloneMacro(Self)
83 
84 
85  virtual std::string GetValueAsString() const override;
93 
95  virtual const VectorType &GetValue() const;
96 
98  virtual void SetValue(const VectorType &parameter_vector);
99 
100  private:
102  VectorProperty &operator=(const Self &);
103 
105  virtual itk::LightObject::Pointer InternalClone() const override;
106 
108  virtual bool IsEqual(const BaseProperty &an_other_property) const override;
109 
111  virtual bool Assign(const BaseProperty &an_other_property) override;
112 
114  VectorType m_PropertyContent;
115  };
116 
118 #define MITK_DECLARE_VECTOR_PROPERTY(TYPE, PREFIX) \
119  \
120  typedef VectorProperty<TYPE> PREFIX##VectorProperty; \
121  \
122  template <> \
123  \
124  struct VectorPropertyDataType<TYPE> \
125  { \
126  static const char *prefix() { return #PREFIX; } \
127  };
128 
130 #define MITK_DEFINE_VECTOR_PROPERTY(TYPE) template class VectorProperty<TYPE>;
131 
134 
135 } // namespace
136 
137 #endif
#define MITKCORE_EXPORT
static const char * prefix()
Helper for VectorProperty to determine a good ITK ClassName.
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
VectorProperty< DATATYPE > Self
static const char * GetStaticNameOfClass()
virtual std::vector< std::string > GetClassHierarchy() const override
Abstract base class for properties.
#define MITK_DECLARE_VECTOR_PROPERTY(TYPE, PREFIX)
This should be used in .h files.
static const char * GetStaticNameOfClass()
int Int
Definition: jsoncpp.h:158
itk::SmartPointer< Self > Pointer
std::vector< DATATYPE > VectorType
Providing a std::vector as property.
virtual const char * GetNameOfClass() const override
itk::SmartPointer< const Self > ConstPointer