Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkBaseProperty.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 mitkBaseProperty_h
14 #define mitkBaseProperty_h
15 
16 #include <MitkCoreExports.h>
17 #include <itkObjectFactory.h>
18 #include <mitkCommon.h>
19 #include <string>
20 #include <nlohmann/json_fwd.hpp>
21 
22 namespace mitk
23 {
39  class MITKCORE_EXPORT BaseProperty : public itk::Object
40  {
41  public:
43  itkCloneMacro(Self);
44 
58  bool operator==(const BaseProperty &property) const;
59 
78  BaseProperty &operator=(const BaseProperty &property);
79 
93  bool AssignProperty(const BaseProperty &property);
94 
104  virtual std::string GetValueAsString() const;
105 
116  virtual bool ToJSON(nlohmann::json& j) const = 0;
117 
128  virtual bool FromJSON(const nlohmann::json& j) = 0;
129 
136  static const std::string VALUE_CANNOT_BE_CONVERTED_TO_STRING;
137 
138  protected:
140  BaseProperty(const BaseProperty &other);
141 
142  ~BaseProperty() override;
143 
144  private:
149  virtual bool IsEqual(const BaseProperty &property) const = 0;
150 
160  virtual bool Assign(const BaseProperty &) = 0;
161  };
162 
181 
208 
209 } // namespace mitk
210 
211 #endif
#define MITKCORE_EXPORT
Abstract base class for properties.
virtual bool ToJSON(nlohmann::json &j) const =0
Serialize property value(s) to JSON.
mitkClassMacroItkParent(BaseProperty, itk::Object)
~BaseProperty() override
BaseProperty & operator=(const BaseProperty &property)
Assign a property value to this instance.
virtual bool FromJSON(const nlohmann::json &j)=0
Deserialize property value(s) from JSON.
BaseProperty(const BaseProperty &other)
static const std::string VALUE_CANNOT_BE_CONVERTED_TO_STRING
Default return value for properties that cannot be converted to a string.
bool operator==(const BaseProperty &property) const
Compare two properties for equality.
virtual std::string GetValueAsString() const
Return the property value as a human-readable string.
bool AssignProperty(const BaseProperty &property)
Assign a property value to this instance and report success.
nlohmann::json json
Find image slices visible on a given plane.
MITKCORE_EXPORT BaseProperty::Pointer ConvertPropertyFromSelfContainedJson(const nlohmann::json &json)
Deserialize a property from self contained JSON representation.
MITKCORE_EXPORT nlohmann::json ConvertPropertyToSelfContainedJson(const BaseProperty *property)
Serialize a property to self contained JSON.