Medical Imaging Interaction Toolkit  2025.12.02
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 
85  virtual std::string Get(const std::string& key, const std::string& def) const = 0;
86 
96  virtual void Put(const std::string& key, const std::string& value) = 0;
97 
105  virtual int GetInt(const std::string& key, int def) const = 0;
106 
112  virtual void PutInt(const std::string& key, int value) = 0;
113 
120  virtual bool GetBool(const std::string& key, bool def) const = 0;
121 
128  virtual void PutBool(const std::string& key, bool value) = 0;
129 
137  virtual float GetFloat(const std::string& key, float def) const = 0;
138 
144  virtual void PutFloat(const std::string& key, float value) = 0;
145 
153  virtual double GetDouble(const std::string& key, double def) const = 0;
154 
160  virtual void PutDouble(const std::string& key, double value) = 0;
161 
180  virtual std::vector<std::byte> GetByteArray(const std::string& key, const std::byte* def, size_t size) const = 0;
181 
199  virtual void PutByteArray(const std::string& key, const std::byte* array, size_t size) = 0;
200 
210  virtual void Flush() = 0;
211 
217  virtual void Remove(const std::string& key) = 0;
218 
222  virtual void Clear() = 0;
223 
227  virtual std::vector<std::string> Keys() const = 0;
228 
237  virtual std::string Name() const = 0;
238 
245  virtual std::string AbsolutePath() const = 0;
246 
250  virtual std::vector<std::string> ChildrenNames() const = 0;
251 
255  virtual IPreferences* Parent() = 0;
256 
260  virtual const IPreferences* Parent() const = 0;
261 
265  virtual IPreferences* Root() = 0;
266 
270  virtual const IPreferences* Root() const = 0;
271 
282  virtual IPreferences* Node(const std::string& path) = 0;
283 
290  virtual void RemoveNode() = 0;
291 
294  };
295 }
296 
297 #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 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 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 std::vector< std::string > Keys() const =0
Get the names of all properties of this preferences node.
virtual void PutFloat(const std::string &key, float value)=0
Set a float property value.
virtual void Remove(const std::string &key)=0
Remove a property from this preferences node.
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 ~IPreferences()
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 const IPreferences * Root() const =0
virtual IPreferences * Parent()=0
Get the parent preferences node or nullptr in case of the root node.
virtual void Clear()=0
Remove all properties from 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 std::string Name() const =0
Get the name of this preferences node.
Find image slices visible on a given plane.