13 #ifndef mitkPropertyList_h
14 #define mitkPropertyList_h
19 #include <nlohmann/json_fwd.hpp>
64 itkFactorylessNewMacro(Self);
71 typedef std::map<std::string, BaseProperty::Pointer>
PropertyMap;
75 BaseProperty::ConstPointer
GetConstProperty(
const std::string &propertyKey,
const std::string &contextName =
"",
bool fallBackOnDefaultContext =
true)
const override;
76 std::vector<std::string>
GetPropertyKeys(
const std::string &contextName =
"",
bool includeDefaultContext =
false)
const override;
81 void SetProperty(
const std::string &propertyKey,
BaseProperty *property,
const std::string &contextName =
"",
bool fallBackOnDefaultContext =
false)
override;
82 void RemoveProperty(
const std::string &propertyKey,
const std::string &contextName =
"",
bool fallBackOnDefaultContext =
false)
override;
108 template <
typename T>
127 bool Get(
const char *propertyKey,
bool &boolValue)
const;
136 void Set(
const char *propertyKey,
bool boolValue);
145 bool Get(
const char *propertyKey,
int &intValue)
const;
154 void Set(
const char *propertyKey,
int intValue);
163 bool Get(
const char *propertyKey,
float &floatValue)
const;
172 void Set(
const char *propertyKey,
float floatValue);
181 bool Get(
const char *propertyKey,
double &doubleValue)
const;
190 void Set(
const char *propertyKey,
double doubleValue);
199 bool Get(
const char *propertyKey, std::string &stringValue)
const;
208 void Set(
const char *propertyKey,
const char *stringValue);
212 void Set(
const char *propertyKey,
const std::string &stringValue);
226 bool IsEmpty()
const {
return m_Properties.empty(); }
263 itk::LightObject::Pointer InternalClone()
const override;
Abstract base class for properties.
virtual T GetValue() const
Key-value list holding instances of BaseProperty.
bool GetBoolProperty(const char *propertyKey, bool &boolValue) const
Convenience method to access the value of a BoolProperty.
std::map< std::string, BaseProperty::Pointer > PropertyMap
PropertyMap m_Properties
Map of properties.
void SetStringProperty(const char *propertyKey, const char *stringValue)
Convenience method to set the value of a StringProperty.
itk::ModifiedTimeType GetMTime() const override
Get the timestamp of the last change of the map or the last change of one of the properties store in ...
void ToJSON(nlohmann::json &j) const
Serialize the property list to JSON.
void Set(const char *propertyKey, float floatValue)
ShortCut for the above method.
bool Get(const char *propertyKey, int &intValue) const
ShortCut for the above method.
bool GetStringProperty(const char *propertyKey, std::string &stringValue) const
Convenience method to access the value of a StringProperty.
mitkClassMacroItkParent(PropertyList, itk::Object)
void RemoveProperty(const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Removes a property. If the property does not exist, nothing will be done.
bool Get(const char *propertyKey, double &doubleValue) const
ShortCut for the above method.
bool Get(const char *propertyKey, std::string &stringValue) const
ShortCut for the above method.
void SetDoubleProperty(const char *propertyKey, double doubleValue)
Convenience method to set the value of a DoubleProperty.
BaseProperty::ConstPointer GetConstProperty(const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
Get property by its key.
std::vector< std::string > GetPropertyContextNames() const override
Query names of existing contexts.
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
void Set(const char *propertyKey, int intValue)
ShortCut for the above method.
bool GetDoubleProperty(const char *propertyKey, double &doubleValue) const
Convenience method to access the value of a DoubleProperty.
bool DeleteProperty(const std::string &propertyKey)
Remove a property from the list/map.
std::vector< std::string > GetPropertyKeys(const std::string &contextName="", bool includeDefaultContext=false) const override
Query keys of existing properties.
BaseProperty * GetNonConstProperty(const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
Get property by its key.
bool Get(const char *propertyKey, float &floatValue) const
ShortCut for the above method.
bool GetPropertyValue(const char *propertyKey, T &value) const
Convenience access method for GenericProperty<T> properties (T being the type of the second parameter...
bool GetFloatProperty(const char *propertyKey, float &floatValue) const
Convenience method to access the value of a FloatProperty.
void FromJSON(const nlohmann::json &j)
Deserialize the property list from JSON.
mitk::BaseProperty * GetProperty(const std::string &propertyKey) const
Get a property by its name.
void Set(const char *propertyKey, bool boolValue)
ShortCut for the above method.
void Set(const char *propertyKey, const char *stringValue)
ShortCut for the above method.
void ReplaceProperty(const std::string &propertyKey, BaseProperty *property)
Set a property object in the list/map by reference.
const PropertyMap * GetMap() const
void Set(const char *propertyKey, double doubleValue)
ShortCut for the above method.
void SetIntProperty(const char *propertyKey, int intValue)
Convenience method to set the value of an IntProperty.
void Set(const char *propertyKey, const std::string &stringValue)
ShortCut for the above method.
std::pair< std::string, BaseProperty::Pointer > PropertyMapElementType
void SetFloatProperty(const char *propertyKey, float floatValue)
Convenience method to set the value of a FloatProperty.
bool GetIntProperty(const char *propertyKey, int &intValue) const
Convenience method to access the value of an IntProperty.
void ConcatenatePropertyList(PropertyList *pList, bool replace=false)
Set a property object in the list/map by reference.
void SetBoolProperty(const char *propertyKey, bool boolValue)
Convenience method to set the value of a BoolProperty.
PropertyList(const PropertyList &other)
bool Get(const char *propertyKey, bool &boolValue) const
ShortCut for the above method.
Find image slices visible on a given plane.
static const char * replace[]
This is a dictionary to replace long names of classes, modules, etc. to shorter versions in the conso...