13 #ifndef mitkPropertyList_h
14 #define mitkPropertyList_h
19 #include <nlohmann/json_fwd.hpp>
62 itkFactorylessNewMacro(Self);
69 typedef std::map<std::string, BaseProperty::Pointer>
PropertyMap;
84 BaseProperty::ConstPointer
GetConstProperty(
const std::string &propertyKey,
const std::string &contextName =
"",
bool fallBackOnDefaultContext =
true)
const override;
97 std::vector<std::string>
GetPropertyKeys(
const std::string &contextName =
"",
bool includeDefaultContext =
false)
const override;
142 void SetProperty(
const std::string &propertyKey,
BaseProperty *property,
const std::string &contextName =
"",
bool fallBackOnDefaultContext =
false)
override;
153 void RemoveProperty(
const std::string &propertyKey,
const std::string &contextName =
"",
bool fallBackOnDefaultContext =
false)
override;
208 template <
typename T>
236 bool Get(
const char *propertyKey,
bool &boolValue)
const;
254 void Set(
const char *propertyKey,
bool boolValue);
272 bool Get(
const char *propertyKey,
int &intValue)
const;
290 void Set(
const char *propertyKey,
int intValue);
308 bool Get(
const char *propertyKey,
float &floatValue)
const;
326 void Set(
const char *propertyKey,
float floatValue);
344 bool Get(
const char *propertyKey,
double &doubleValue)
const;
362 void Set(
const char *propertyKey,
double doubleValue);
380 bool Get(
const char *propertyKey, std::string &stringValue)
const;
398 void Set(
const char *propertyKey,
const char *stringValue);
406 void Set(
const char *propertyKey,
const std::string &stringValue);
438 bool IsEmpty()
const {
return m_Properties.empty(); }
Abstract base class for properties.
Template class for generating properties for simple value types (int, float, bool,...
virtual T GetValue() const
Get the property value.
Interface implemented by classes that provide write/read access to property information.
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 modification timestamp of the list.
void ToJSON(nlohmann::json &j) const
Serialize the property list to JSON.
void Set(const char *propertyKey, float floatValue)
Shortcut for SetFloatProperty().
bool Get(const char *propertyKey, int &intValue) const
Shortcut for GetIntProperty().
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
Remove a property from the list by key.
bool Get(const char *propertyKey, double &doubleValue) const
Shortcut for GetDoubleProperty().
PropertyList(const Self &other)
bool Get(const char *propertyKey, std::string &stringValue) const
Shortcut for GetStringProperty().
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
Retrieve a property by key (const version).
std::vector< std::string > GetPropertyContextNames() const override
Return available property context names.
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Set a property in the list, preserving existing property type.
void Set(const char *propertyKey, int intValue)
Shortcut for SetIntProperty().
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 by key.
std::vector< std::string > GetPropertyKeys(const std::string &contextName="", bool includeDefaultContext=false) const override
Retrieve all property keys.
BaseProperty * GetNonConstProperty(const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
Retrieve a property by key (non-const version).
bool Get(const char *propertyKey, float &floatValue) const
Shortcut for GetFloatProperty().
bool GetPropertyValue(const char *propertyKey, T &value) const
Convenience access method for GenericProperty<T> properties.
bool GetFloatProperty(const char *propertyKey, float &floatValue) const
Convenience method to access the value of a FloatProperty.
bool IsEmpty() const
Check whether the property list contains no properties.
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 SetBoolProperty().
virtual void Clear()
Remove all properties from the list.
void Set(const char *propertyKey, const char *stringValue)
Shortcut for SetStringProperty() accepting a C-string.
void ReplaceProperty(const std::string &propertyKey, BaseProperty *property)
Replace a property object in the list by a new one.
const PropertyMap * GetMap() const
Get a read-only pointer to the internal property map.
void Set(const char *propertyKey, double doubleValue)
Shortcut for SetDoubleProperty().
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 SetStringProperty() accepting a std::string.
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)
Merge another PropertyList into this one.
void SetBoolProperty(const char *propertyKey, bool boolValue)
Convenience method to set the value of a BoolProperty.
bool Get(const char *propertyKey, bool &boolValue) const
Shortcut for GetBoolProperty().
Find image slices visible on a given plane.
static const char * replace[]
Dictionary for abbreviating class, module, and namespace names in log output.
MITKCORE_EXPORT nlohmann::json ConvertPropertyListToSelfContainedJson(const mitk::PropertyList *propertyList)
Serialize all properties from a PropertyList to self contained JSON representations.
MITKCORE_EXPORT PropertyList::Pointer ConvertPropertyListFromSelfContainedJson(const nlohmann::json &json)
Deserialize a property list from self contained JSON representations.