Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkPersistenceService.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 #ifndef mitkPersistenceService_h
13 #define mitkPersistenceService_h
14 
17 #include <mitkSceneIO.h>
18 #include <MitkPersistenceExports.h>
19 #include <itkLightObject.h>
20 
21 namespace mitk
22 {
41  {
42  public:
48  static std::string GetPersistencePropertyName();
49 
55  static std::string GetPersistencePropertyListName();
56 
63  static void LoadModule();
64 
71 
73 
74  ~PersistenceService() override;
75 
84  std::string GetDefaultPersistenceFile() override;
85 
97  mitk::PropertyList::Pointer GetPropertyList(std::string &id, bool *existed = nullptr) override;
98 
105  bool RemovePropertyList(std::string &id) override;
106 
113  std::string GetPersistenceNodePropertyName() override;
114 
125  DataStorage::SetOfObjects::Pointer GetDataNodes(DataStorage *ds = nullptr) override;
126 
138  bool Save(const std::string &fileName = "", bool appendChanges = false) override;
139 
154  bool Load(const std::string &fileName = "", bool enforeReload = true) override;
155 
164  void SetAutoLoadAndSave(bool autoLoadAndSave) override;
165 
171  bool GetAutoLoadAndSave() override;
172 
180 
188 
201 
205  void Clear();
206 
213  void Unitialize();
214 
215  private:
216  void ClonePropertyList(mitk::PropertyList *from, mitk::PropertyList *to) const;
217  void Initialize();
218  std::map<std::string, mitk::PropertyList::Pointer> m_PropertyLists;
219  bool m_AutoLoadAndSave;
220  std::set<PropertyListReplacedObserver *> m_PropertyListReplacedObserver;
221  SceneIO::Pointer m_SceneIO;
222  PropertyListsXmlFileReaderAndWriter::Pointer m_PropertyListsXmlFileReaderAndWriter;
223  std::map<std::string, long int> m_FileNamesToModifiedTimes;
224  bool m_Initialized;
225  bool m_InInitialized;
226  };
227 }
228 #endif
#define MITKPERSISTENCE_EXPORT
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
The central service for the persistence module.
Concrete implementation of the IPersistenceService interface.
void SetAutoLoadAndSave(bool autoLoadAndSave) override
Enable or disable automatic loading and saving of property lists.
mitk::PropertyList::Pointer GetPropertyList(std::string &id, bool *existed=nullptr) override
Retrieve or create a PropertyList identified by the given id.
bool Save(const std::string &fileName="", bool appendChanges=false) override
Save all property lists to a file.
bool RemovePropertyList(std::string &id) override
Remove the PropertyList identified by the given id.
static std::string GetPersistencePropertyListName()
Get the property list name used for internal persistence service settings.
static std::string GetPersistencePropertyName()
Get the property name used to mark DataNodes as persistence nodes.
std::string GetPersistenceNodePropertyName() override
Get the name of the boolean property used to tag persistence DataNodes.
static void LoadModule()
Trigger loading of the persistence module.
void RemovePropertyListReplacedObserver(PropertyListReplacedObserver *observer) override
Unregister a previously added PropertyListReplacedObserver.
static us::ModuleContext * GetModuleContext()
Get the micro services module context for this module.
DataStorage::SetOfObjects::Pointer GetDataNodes(DataStorage *ds=nullptr) override
Create DataNodes from all stored PropertyLists and optionally add them to a DataStorage.
bool GetAutoLoadAndSave() override
Query whether automatic loading and saving is enabled.
void AddPropertyListReplacedObserver(PropertyListReplacedObserver *observer) override
Register an observer to be notified when a PropertyList is replaced during Load().
bool RestorePropertyListsFromPersistentDataNodes(const DataStorage *storage) override
Restore property lists from persistence-tagged DataNodes in a DataStorage.
bool Load(const std::string &fileName="", bool enforeReload=true) override
Load property lists from a file.
void Unitialize()
Shut down the persistence service.
void Clear()
Clear all stored property lists and file modification time records.
std::string GetDefaultPersistenceFile() override
Get the default file path used for persisting property lists.
~PersistenceService() override
Observer that gets informed when a PropertyList with a given id is replaced during a Load() process.
Key-value list holding instances of BaseProperty.
Find image slices visible on a given plane.