Medical Imaging Interaction Toolkit  2023.12.99-63768887
Medical Imaging Interaction Toolkit
mitk::PersistenceService Class Reference

#include <mitkPersistenceService.h>

Inheritance diagram for mitk::PersistenceService:
Collaboration diagram for mitk::PersistenceService:

Public Member Functions

 PersistenceService ()
 
 ~PersistenceService () override
 
std::string GetDefaultPersistenceFile () override
 
mitk::PropertyList::Pointer GetPropertyList (std::string &id, bool *existed=nullptr) override
 
bool RemovePropertyList (std::string &id) override
 
std::string GetPersistenceNodePropertyName () override
 
DataStorage::SetOfObjects::Pointer GetDataNodes (DataStorage *ds=nullptr) override
 
bool Save (const std::string &fileName="", bool appendChanges=false) override
 
bool Load (const std::string &fileName="", bool enforeReload=true) override
 
void SetAutoLoadAndSave (bool autoLoadAndSave) override
 
bool GetAutoLoadAndSave () override
 
void AddPropertyListReplacedObserver (PropertyListReplacedObserver *observer) override
 
void RemovePropertyListReplacedObserver (PropertyListReplacedObserver *observer) override
 
bool RestorePropertyListsFromPersistentDataNodes (const DataStorage *storage) override
 
void Clear ()
 
void Unitialize ()
 
- Public Member Functions inherited from mitk::IPersistenceService
virtual ~IPersistenceService ()
 

Static Public Member Functions

static std::string GetPersistencePropertyName ()
 
static std::string GetPersistencePropertyListName ()
 
static void LoadModule ()
 
static us::ModuleContext * GetModuleContext ()
 

Detailed Description

implementation of the IPersistenceService

See also
IPersistenceService

Definition at line 26 of file mitkPersistenceService.h.

Constructor & Destructor Documentation

◆ PersistenceService()

mitk::PersistenceService::PersistenceService ( )

◆ ~PersistenceService()

mitk::PersistenceService::~PersistenceService ( )
override

Member Function Documentation

◆ AddPropertyListReplacedObserver()

void mitk::PersistenceService::AddPropertyListReplacedObserver ( PropertyListReplacedObserver observer)
overridevirtual

adds a observer which is informed if a propertyList gets replaced during a Load() procedure

Implements mitk::IPersistenceService.

◆ Clear()

void mitk::PersistenceService::Clear ( )

◆ GetAutoLoadAndSave()

bool mitk::PersistenceService::GetAutoLoadAndSave ( )
overridevirtual
Returns
whether AutoLoading is activated or not

Implements mitk::IPersistenceService.

◆ GetDataNodes()

DataStorage::SetOfObjects::Pointer mitk::PersistenceService::GetDataNodes ( DataStorage ds = nullptr)
overridevirtual

Creates a vector of DataNodes that contain all PropertyLists. Additionally, the DataNodes will have the property name set to the PropertyList's id and a BoolProperty equal to GetPersistenceNodePropertyName() set to true. If ds is set the returned DataNodes will also be added to that DS.

Returns
vector of DataNodes with the described attributes

Implements mitk::IPersistenceService.

◆ GetDefaultPersistenceFile()

std::string mitk::PersistenceService::GetDefaultPersistenceFile ( )
overridevirtual

Get the default name of the PersistenceFile (the one that is loaded at startup)

Implements mitk::IPersistenceService.

◆ GetModuleContext()

static us::ModuleContext* mitk::PersistenceService::GetModuleContext ( )
static

◆ GetPersistenceNodePropertyName()

std::string mitk::PersistenceService::GetPersistenceNodePropertyName ( )
overridevirtual
Returns
The name of the Bool Property that specifies whether a DataNode is a Node carrying Persistence PropertyLists

Implements mitk::IPersistenceService.

◆ GetPersistencePropertyListName()

static std::string mitk::PersistenceService::GetPersistencePropertyListName ( )
static

◆ GetPersistencePropertyName()

static std::string mitk::PersistenceService::GetPersistencePropertyName ( )
static

◆ GetPropertyList()

mitk::PropertyList::Pointer mitk::PersistenceService::GetPropertyList ( std::string &  id,
bool *  existed = nullptr 
)
overridevirtual

If PropertyList with the given id exists, returns it. Otherwise creates a new one and returns it. If id is empty a UUID will be created and set on the variable If existed was passed, it is true if the PropertyList with that id existed, false otherwise

Returns
a valid PropertyList with a StringProperty "Id" containing the passed id

Implements mitk::IPersistenceService.

◆ Load()

bool mitk::PersistenceService::Load ( const std::string &  fileName = "",
bool  enforeReload = true 
)
overridevirtual

Load PropertyLists from fileName. If fileName is empty, a special file in the users home directory will be used. If enforeReload is false, the service will take care of modified time flags, i.e. it will not load a file that was loaded before and did not change in the meantime or that was modified by the service itself ATTENTION: If there are PropertyLists with the same id contained in the file, existing PropertyLists will be overwritten!

See also
AddPropertyListReplacedObserver()
Returns
false if an error occurred (cannot load from file), true otherwise

Implements mitk::IPersistenceService.

◆ LoadModule()

static void mitk::PersistenceService::LoadModule ( )
static

◆ RemovePropertyList()

bool mitk::PersistenceService::RemovePropertyList ( std::string &  id)
overridevirtual

removes the PropertyList with the given id

Returns
true if PropertyList existed and could be removed, false otherwise

Implements mitk::IPersistenceService.

◆ RemovePropertyListReplacedObserver()

void mitk::PersistenceService::RemovePropertyListReplacedObserver ( PropertyListReplacedObserver observer)
overridevirtual

removes a specific observer

Implements mitk::IPersistenceService.

◆ RestorePropertyListsFromPersistentDataNodes()

bool mitk::PersistenceService::RestorePropertyListsFromPersistentDataNodes ( const DataStorage storage)
overridevirtual

Searches storage for persistent DataNodes, extracts and inserts the appended property lists to this service

Returns
true if at least one node was found from which a PropertyList could be restored

Implements mitk::IPersistenceService.

◆ Save()

bool mitk::PersistenceService::Save ( const std::string &  fileName = "",
bool  appendChanges = false 
)
overridevirtual

Save the current PropertyLists to fileName. If fileName is empty, a special file in the users home directory will be used. if appendchanges is true, the file will not replaced but first loaded, then overwritten and then replaced

Returns
false if an error occurred (cannot write to file), true otherwise

Implements mitk::IPersistenceService.

◆ SetAutoLoadAndSave()

void mitk::PersistenceService::SetAutoLoadAndSave ( bool  autoLoadAndSave)
overridevirtual

Using SetAutoLoadAndSave(true) will cause the service to load/save the property lists at application start/stop.

Implements mitk::IPersistenceService.

◆ Unitialize()

void mitk::PersistenceService::Unitialize ( )

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