Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::XMLPreferencesStorage Class Reference

XML file-backed implementation of IPreferencesStorage. More...

#include <mitkXMLPreferencesStorage.h>

Inheritance diagram for mitk::XMLPreferencesStorage:
Collaboration diagram for mitk::XMLPreferencesStorage:

Public Member Functions

 XMLPreferencesStorage (const fs::path &filename)
 Construct storage backed by the given XML file. More...
 
 ~XMLPreferencesStorage () override
 
void Flush () override
 Serialize the entire preferences tree to the backing XML file. More...
 
- Public Member Functions inherited from mitk::IPreferencesStorage
 IPreferencesStorage (const fs::path &filename)
 Constructor. Load preferences from the specified file. More...
 
virtual ~IPreferencesStorage ()
 Destructor. Write preferences to disk for the last time. More...
 
virtual IPreferences * GetRoot ()
 Get the preferences root node. More...
 
virtual const IPreferences * GetRoot () const
 
virtual fs::path GetFilename () const
 Get the filename of the preferences storage. More...
 

Additional Inherited Members

- Protected Attributes inherited from mitk::IPreferencesStorage
fs::path m_Filename
 
std::unique_ptr< IPreferences > m_Root
 

Detailed Description

XML file-backed implementation of IPreferencesStorage.

Persists the preferences tree to an XML file using TinyXML2. On construction, loads existing preferences from the file if it exists, otherwise creates an empty root node and ensures the parent directory exists. On Flush(), serializes the entire preferences tree back to the file.

See also
IPreferencesStorage
Preferences
PreferencesService

Definition at line 32 of file mitkXMLPreferencesStorage.h.

Constructor & Destructor Documentation

◆ XMLPreferencesStorage()

mitk::XMLPreferencesStorage::XMLPreferencesStorage ( const fs::path &  filename)
explicit

Construct storage backed by the given XML file.

If the file exists, its contents are deserialized into the preferences tree. Otherwise, parent directories are created and an empty root node is initialized.

Parameters
[in]filenamePath to the XML preferences file.

◆ ~XMLPreferencesStorage()

mitk::XMLPreferencesStorage::~XMLPreferencesStorage ( )
override

Member Function Documentation

◆ Flush()

void mitk::XMLPreferencesStorage::Flush ( )
overridevirtual

Serialize the entire preferences tree to the backing XML file.

Overwrites the file with the current state of all preferences nodes.

Implements mitk::IPreferencesStorage.


The documentation for this class was generated from the following file: