Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkIPreferences.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 mitkIPreferences_h
14 #define mitkIPreferences_h
15 
16 #include <mitkMessage.h>
17 
18 #include <MitkCoreExports.h>
19 
20 #include <cstddef>
21 #include <string>
22 #include <vector>
23 
24 namespace mitk
25 {
51  {
52  public:
57  {
58  public:
59  ChangeEvent(IPreferences* source, const std::string& property, const std::string& oldValue, const std::string& newValue);
60 
62  std::string GetProperty() const;
63  std::string GetOldValue() const;
64  std::string GetNewValue() const;
65 
66  private:
67  IPreferences* m_Source;
68  std::string m_Property;
69  std::string m_OldValue;
70  std::string m_NewValue;
71  };
72 
73  virtual ~IPreferences();
74 
89  virtual std::string Get(const std::string& key, const std::string& def) const = 0;
90 
102  virtual void Put(const std::string& key, const std::string& value) = 0;
103 
111  virtual int GetInt(const std::string& key, int def) const = 0;
112 
118  virtual void PutInt(const std::string& key, int value) = 0;
119 
126  virtual bool GetBool(const std::string& key, bool def) const = 0;
127 
134  virtual void PutBool(const std::string& key, bool value) = 0;
135 
143  virtual float GetFloat(const std::string& key, float def) const = 0;
144 
150  virtual void PutFloat(const std::string& key, float value) = 0;
151 
159  virtual double GetDouble(const std::string& key, double def) const = 0;
160 
166  virtual void PutDouble(const std::string& key, double value) = 0;
167 
186  virtual std::vector<std::byte> GetByteArray(const std::string& key, const std::byte* def, size_t size) const = 0;
187 
205  virtual void PutByteArray(const std::string& key, const std::byte* array, size_t size) = 0;
206 
216  virtual void Override(const std::string& key, const std::string& value) = 0;
217 
223  virtual void OverrideInt(const std::string& key, int value) = 0;
224 
230  virtual void OverrideBool(const std::string& key, bool value) = 0;
231 
237  virtual void OverrideFloat(const std::string& key, float value) = 0;
238 
244  virtual void OverrideDouble(const std::string& key, double value) = 0;
245 
251  virtual void OverrideByteArray(const std::string& key, const std::byte* array, size_t size) = 0;
252 
256  virtual bool IsOverridden(const std::string& key) const = 0;
257 
263  virtual void RemoveOverride(const std::string& key) = 0;
264 
268  virtual void ClearOverrides() = 0;
269 
280  virtual void Flush() = 0;
281 
296  virtual bool Remove(const std::string& key, bool forceRemoval = false) = 0;
297 
308  virtual void Clear(bool includeOverrides = false) = 0;
309 
315  virtual std::vector<std::string> Keys(bool includeOverrides = false) const = 0;
316 
325  virtual std::string Name() const = 0;
326 
333  virtual std::string AbsolutePath() const = 0;
334 
338  virtual std::vector<std::string> ChildrenNames() const = 0;
339 
343  virtual IPreferences* Parent() = 0;
344 
348  virtual const IPreferences* Parent() const = 0;
349 
353  virtual IPreferences* Root() = 0;
354 
358  virtual const IPreferences* Root() const = 0;
359 
370  virtual IPreferences* Node(const std::string& path) = 0;
371 
378  virtual void RemoveNode() = 0;
379 
382  };
383 
396  MITKCORE_EXPORT void ApplyPreferencesOverrides(const std::string& xmlContent, IPreferences* prefs);
397 
411  MITKCORE_EXPORT void ApplyPreferencesPatches(const std::string& xmlContent, IPreferences* prefs);
412 
413 }
414 
415 #endif
#define MITKCORE_EXPORT
Event object sent on IPreferences::OnPropertyChanged events.
std::string GetProperty() const
std::string GetOldValue() const
IPreferences * GetSource() const
std::string GetNewValue() const
ChangeEvent(IPreferences *source, const std::string &property, const std::string &oldValue, const std::string &newValue)
Interface to application preferences.
virtual void OverrideDouble(const std::string &key, double value)=0
Set a session-only override for a double property.
virtual std::vector< std::byte > GetByteArray(const std::string &key, const std::byte *def, size_t size) const =0
Get a property value as typeless binary representation.
virtual void RemoveOverride(const std::string &key)=0
Remove a session-only override for a property.
virtual std::vector< std::string > ChildrenNames() const =0
Get the names of all direct child preference nodes.
virtual std::string AbsolutePath() const =0
Get the absolute path (relative to the root node) of this preferences node.
virtual void PutFloat(const std::string &key, float value)=0
Set a float property value.
virtual double GetDouble(const std::string &key, double def) const =0
Get a property value as double.
virtual void PutDouble(const std::string &key, double value)=0
Set a double property value.
virtual void Put(const std::string &key, const std::string &value)=0
Set a property value.
Message1< const IPreferences * > OnChanged
Notify on node changes.
virtual void PutInt(const std::string &key, int value)=0
Set an int property value.
virtual int GetInt(const std::string &key, int def) const =0
Get a property value as int.
virtual std::string Get(const std::string &key, const std::string &def) const =0
Get a property value as string.
virtual float GetFloat(const std::string &key, float def) const =0
Get a property value as float.
virtual IPreferences * Root()=0
Get the root preferences node.
virtual void PutBool(const std::string &key, bool value)=0
Set a bool property value.
virtual void Clear(bool includeOverrides=false)=0
Remove all properties from this preferences node.
virtual ~IPreferences()
virtual void Override(const std::string &key, const std::string &value)=0
Set a session-only override for a string property.
virtual void Flush()=0
Write all (!) preferences to disk.
virtual void PutByteArray(const std::string &key, const std::byte *array, size_t size)=0
Put binary data into a property value.
virtual void OverrideInt(const std::string &key, int value)=0
Set a session-only override for an int property.
virtual const IPreferences * Root() const =0
virtual IPreferences * Parent()=0
Get the parent preferences node or nullptr in case of the root node.
virtual bool Remove(const std::string &key, bool forceRemoval=false)=0
Remove a property from this preferences node.
virtual void OverrideByteArray(const std::string &key, const std::byte *array, size_t size)=0
Set a session-only override for a byte array property.
virtual void ClearOverrides()=0
Remove all session-only overrides from this preferences node.
virtual std::vector< std::string > Keys(bool includeOverrides=false) const =0
Get the names of all properties of this preferences node.
virtual bool GetBool(const std::string &key, bool def) const =0
Get a property value as bool.
virtual IPreferences * Node(const std::string &path)=0
Get (and possibly create) the preferences node specified by the given path.
virtual const IPreferences * Parent() const =0
Message1< const ChangeEvent & > OnPropertyChanged
Notify on property changes.
virtual void RemoveNode()=0
Remove this preferences node from its parent node.
virtual void OverrideFloat(const std::string &key, float value)=0
Set a session-only override for a float property.
virtual bool IsOverridden(const std::string &key) const =0
Check whether a property has a session-only override.
virtual void OverrideBool(const std::string &key, bool value)=0
Set a session-only override for a bool property.
virtual std::string Name() const =0
Get the name of this preferences node.
Event/message class with one parameter.
Definition: mitkMessage.h:552
Find image slices visible on a given plane.
MITKCORE_EXPORT void ApplyPreferencesOverrides(const std::string &xmlContent, IPreferences *prefs)
Apply preference overrides from XML content.
MITKCORE_EXPORT void ApplyPreferencesPatches(const std::string &xmlContent, IPreferences *prefs)
Permanently patch preferences from an XML string.