Medical Imaging Interaction Toolkit
2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
|
Implementation of the IPreferences interface. More...
#include <mitkPreferences.h>
Public Types | |
using | Properties = std::unordered_map< std::string, std::string > |
Public Member Functions | |
Preferences (const Properties &properties, const std::string &name, Preferences *parent, IPreferencesStorage *storage) | |
~Preferences () override | |
Preferences (const Preferences &)=delete | |
Preferences & | operator= (const Preferences &)=delete |
Preferences (Preferences &&)=default | |
Preferences & | operator= (Preferences &&)=default |
std::string | Get (const std::string &key, const std::string &def) const override |
Get a property value as string. More... | |
void | Put (const std::string &key, const std::string &value) override |
Set a property value. More... | |
int | GetInt (const std::string &key, int def) const override |
Get a property value as int . More... | |
void | PutInt (const std::string &key, int value) override |
Set an int property value. More... | |
bool | GetBool (const std::string &key, bool def) const override |
Get a property value as bool . More... | |
void | PutBool (const std::string &key, bool value) override |
Set a bool property value. More... | |
float | GetFloat (const std::string &key, float def) const override |
Get a property value as float . More... | |
void | PutFloat (const std::string &key, float value) override |
Set a float property value. More... | |
double | GetDouble (const std::string &key, double def) const override |
Get a property value as double . More... | |
void | PutDouble (const std::string &key, double value) override |
Set a double property value. More... | |
std::vector< std::byte > | GetByteArray (const std::string &key, const std::byte *def, size_t size) const override |
Get a property value as typeless binary representation. More... | |
void | PutByteArray (const std::string &key, const std::byte *array, size_t size) override |
Put binary data into a property value. More... | |
void | Remove (const std::string &key) override |
Remove a property from this preferences node. More... | |
void | Clear () override |
Remove all properties from this preferences node. More... | |
std::vector< std::string > | Keys () const override |
Get the names of all properties of this preferences node. More... | |
std::vector< std::string > | ChildrenNames () const override |
Get the names of all direct child preference nodes. More... | |
IPreferences * | Parent () override |
Get the parent preferences node or nullptr in case of the root node. More... | |
const IPreferences * | Parent () const override |
IPreferences * | Root () override |
Get the root preferences node. More... | |
const IPreferences * | Root () const override |
IPreferences * | Node (const std::string &path) override |
Get (and possibly create) the preferences node specified by the given path. More... | |
void | RemoveNode () override |
Remove this preferences node from its parent node. More... | |
std::string | Name () const override |
Get the name of this preferences node. More... | |
std::string | AbsolutePath () const override |
Get the absolute path (relative to the root node) of this preferences node. More... | |
void | Flush () override |
Write all (!) preferences to disk. More... | |
const Properties & | GetProperties () const |
const std::vector< std::unique_ptr< Preferences > > & | GetChildren () const |
Public Member Functions inherited from mitk::IPreferences | |
virtual | ~IPreferences () |
Additional Inherited Members | |
Public Attributes inherited from mitk::IPreferences | |
Message1< const IPreferences * > | OnChanged |
Notify on node changes. More... | |
Message1< const ChangeEvent & > | OnPropertyChanged |
Notify on property changes. More... | |
Implementation of the IPreferences interface.
Only used through the IPreferences interface.
Definition at line 32 of file mitkPreferences.h.
using mitk::Preferences::Properties = std::unordered_map<std::string, std::string> |
Definition at line 35 of file mitkPreferences.h.
mitk::Preferences::Preferences | ( | const Properties & | properties, |
const std::string & | name, | ||
Preferences * | parent, | ||
IPreferencesStorage * | storage | ||
) |
|
override |
|
delete |
|
default |
|
overridevirtual |
Get the absolute path (relative to the root node) of this preferences node.
Implements mitk::IPreferences.
|
overridevirtual |
Get the names of all direct child preference nodes.
Implements mitk::IPreferences.
|
overridevirtual |
Remove all properties from this preferences node.
Implements mitk::IPreferences.
|
overridevirtual |
Write all (!) preferences to disk.
Enforce the persistence of the whole preferences tree.
Implements mitk::IPreferences.
|
overridevirtual |
Get a property value as string.
If the property cannot be found, return the provided default value instead.
key | Name of the property |
def | Default value |
Implements mitk::IPreferences.
|
overridevirtual |
Get a property value as bool
.
Convenience wrapper of Get() checking if the string value literally equals "true"
. Returns false otherwise. The comparison is case-insensitive.
Implements mitk::IPreferences.
|
overridevirtual |
Get a property value as typeless binary representation.
Decode a Base64-encoded property value into a typeless binary representation. Use reinterpret_cast
to restore the original type:
key | Name of the property |
def | Raw pointer to the default binary data or nullptr |
size | Size of the default binary data in bytes or 0 in case of nullptr |
std::vector::data()
to get a raw pointer to the data. Implements mitk::IPreferences.
const std::vector<std::unique_ptr<Preferences> >& mitk::Preferences::GetChildren | ( | ) | const |
|
overridevirtual |
Get a property value as double
.
Convenience wrapper of Get() undertaking string to double
conversion.
Exception | The property value is not a valid string representation of a double value. |
Implements mitk::IPreferences.
|
overridevirtual |
Get a property value as float
.
Convenience wrapper of Get() undertaking string to float
conversion.
Exception | The property value is not a valid string representation of a float value. |
Implements mitk::IPreferences.
|
overridevirtual |
Get a property value as int
.
Convenience wrapper of Get() undertaking string to integer conversion.
Exception | The property value is not a valid string representation of an int value. |
Implements mitk::IPreferences.
const Properties& mitk::Preferences::GetProperties | ( | ) | const |
|
overridevirtual |
Get the names of all properties of this preferences node.
Implements mitk::IPreferences.
|
overridevirtual |
Get the name of this preferences node.
The name can be used in an absolute or relative path separated by forward slashes to address a specific properties node.
Implements mitk::IPreferences.
|
overridevirtual |
Get (and possibly create) the preferences node specified by the given path.
The path is considered to be absolute if it starts with a forward slash. It is relative to this preferences node otherwise. If any preferences node does not yet exist during traversal, it is created on the fly.
Implements mitk::IPreferences.
|
delete |
|
default |
|
overridevirtual |
Implements mitk::IPreferences.
|
overridevirtual |
Get the parent preferences node or nullptr
in case of the root node.
Implements mitk::IPreferences.
|
overridevirtual |
Set a property value.
Create the property if not yet existent. Otherwise change its value.
Trigger an IPreferences::OnPropertyChanged event if the new value is different or if a new property has been created, except the string value is empty in the latter case.
Implements mitk::IPreferences.
|
overridevirtual |
Set a bool
property value.
Convenience wrapper of Put() using the literal strings "true"
and "false"
to encode the bool
value.
Implements mitk::IPreferences.
|
overridevirtual |
Put binary data into a property value.
The Base64 algorithm is used to encode binary data into a valid text representation. Use reinterpret_cast
to pass a raw pointer to binary data and specify its total number of bytes:
key | Name of the property |
array | Raw pointer to binary data |
size | Size of the binary data in bytes |
Implements mitk::IPreferences.
|
overridevirtual |
Set a double
property value.
Convenience wrapper of Put() undertaking double
to string conversion.
Implements mitk::IPreferences.
|
overridevirtual |
Set a float
property value.
Convenience wrapper of Put() undertaking float
to string conversion.
Implements mitk::IPreferences.
|
overridevirtual |
Set an int
property value.
Convenience wrapper of Put() undertaking integer to string conversion.
Implements mitk::IPreferences.
|
overridevirtual |
Remove a property from this preferences node.
key | Name of the property |
Implements mitk::IPreferences.
|
overridevirtual |
Remove this preferences node from its parent node.
Implements mitk::IPreferences.
|
overridevirtual |
Implements mitk::IPreferences.
|
overridevirtual |
Get the root preferences node.
Implements mitk::IPreferences.