Medical Imaging Interaction Toolkit  2016.11.0
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 ()
 
std::string GetDefaultPersistenceFile () override
 
mitk::PropertyList::Pointer GetPropertyList (std::string &id, bool *existed=0) override
 
bool RemovePropertyList (std::string &id) override
 
std::string GetPersistenceNodePropertyName () override
 
DataStorage::SetOfObjects::Pointer GetDataNodes (DataStorage *ds=0) 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 30 of file mitkPersistenceService.h.

Constructor & Destructor Documentation

mitk::PersistenceService::PersistenceService ( )

Definition at line 35 of file mitkPersistenceService.cpp.

mitk::PersistenceService::~PersistenceService ( )

Definition at line 46 of file mitkPersistenceService.cpp.

References MITK_DEBUG.

Member Function Documentation

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.

Definition at line 270 of file mitkPersistenceService.cpp.

void mitk::PersistenceService::Clear ( )

Definition at line 39 of file mitkPersistenceService.cpp.

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

Implements mitk::IPersistenceService.

Definition at line 377 of file mitkPersistenceService.cpp.

mitk::DataStorage::SetOfObjects::Pointer mitk::PersistenceService::GetDataNodes ( DataStorage ds = 0)
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.

Definition at line 298 of file mitkPersistenceService.cpp.

References mitk::DataStorage::Add(), MITK_DEBUG, mitk::New(), and mitk::DataNode::New().

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

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

Implements mitk::IPersistenceService.

Definition at line 51 of file mitkPersistenceService.cpp.

References us::GetModuleContext().

Referenced by Load(), and Save().

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

Definition at line 287 of file mitkPersistenceService.cpp.

References us::GetModuleContext().

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.

Definition at line 292 of file mitkPersistenceService.cpp.

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

Definition at line 30 of file mitkPersistenceService.cpp.

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

Definition at line 25 of file mitkPersistenceService.cpp.

mitk::PropertyList::Pointer mitk::PersistenceService::GetPropertyList ( std::string &  id,
bool *  existed = 0 
)
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.

Definition at line 65 of file mitkPersistenceService.cpp.

References mitk::UIDGenerator::GetUID(), and mitk::PropertyList::New().

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 occured (cannot load from file), true otherwise

Implements mitk::IPersistenceService.

Definition at line 194 of file mitkPersistenceService.cpp.

References GetDefaultPersistenceFile(), MITK_DEBUG, and mitk::SceneIO::New().

void mitk::PersistenceService::LoadModule ( )
static

Definition at line 282 of file mitkPersistenceService.cpp.

References MITK_DEBUG.

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.

Definition at line 383 of file mitkPersistenceService.cpp.

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

removes a specific observer

Implements mitk::IPersistenceService.

Definition at line 276 of file mitkPersistenceService.cpp.

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.

Definition at line 324 of file mitkPersistenceService.cpp.

References mitk::DataStorage::GetAll(), mitk::DataNode::GetBoolProperty(), mitk::DataNode::GetName(), mitk::DataNode::GetPropertyList(), and MITK_DEBUG.

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 occured (cannot write to file), true otherwise

Implements mitk::IPersistenceService.

Definition at line 108 of file mitkPersistenceService.cpp.

References GetDefaultPersistenceFile(), MITK_ERROR, mitk::SceneIO::New(), and mitk::StandaloneDataStorage::New().

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.

Definition at line 259 of file mitkPersistenceService.cpp.

void mitk::PersistenceService::Unitialize ( )

Definition at line 422 of file mitkPersistenceService.cpp.


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