this class is responsible for managing the persistency mechanism of the classes. More...
#include <PersistencyManager.h>
Public Member Functions | |
void | registerPersistencyUnit (PersistencyUnit *pPersistencyUnit) |
this method adds a new persistence unit to the manager | |
void | start () |
starts the persistency process | |
void | trigger (const std::string &className) |
this method triggers the store procedure that saves the persistent fields of the class passed as a parameter into the persistency file | |
Static Public Member Functions | |
static PersistencyManager * | getInstance () |
returns the unique object instance of this class in the system | |
Protected Member Functions | |
PersistencyManager () | |
void | run () |
this method contains the logic of the persistent manager | |
void | store (PersistencyUnit &pPersistencyUnit) |
this method makes stores the information about the data stores contained in the persistent unit passed by parameter | |
virtual | ~PersistencyManager () |
destructor | |
Protected Attributes | |
ConditionalVariable | triggerCondVar_ |
conditional variable to trigger the persistency procedure | |
Mutex | accessMutex_ |
mutex to protect the access to the persistent units | |
std::map< const std::string, PersistencyUnit * > | persistencyUnitsCol_ |
this hasmap contains all the persistent units | |
std::set< PersistencyUnit * > | persistencySet_ |
queue that stores the persistency units that have to be stored | |
uint32_t | persistencyMaxDelay_ |
delay of the persistency mechanism, it is triggered after persistencyMaxDelay seconds | |
bool | isStarted_ |
true if the persistent manager started | |
StoreManager | storeManager_ |
stores the persistent units | |
uint32_t | counterOfTriggers_ |
stores counters of persistent triggers The value is reset to zero when saving in a file. It is used to avoid that an avalanche of triggers produces a massive number of editions of the file. | |
Static Protected Attributes | |
static PersistencyManager * | theInstance_ = NULL |
instance of the singleton object |
this class is responsible for managing the persistency mechanism of the classes.
Definition at line 25 of file PersistencyManager.h.
fesa::PersistencyManager::PersistencyManager | ( | ) | [protected] |
Definition at line 39 of file PersistencyManager.cpp.
References getInstance(), fesa::PropertyTag::MAX_PERSISTENCY_DELAY, and persistencyMaxDelay_.
Referenced by getInstance().
fesa::PersistencyManager::~PersistencyManager | ( | ) | [protected, virtual] |
PersistencyManager * fesa::PersistencyManager::getInstance | ( | ) | [static] |
returns the unique object instance of this class in the system
Definition at line 54 of file PersistencyManager.cpp.
References PersistencyManager(), and theInstance_.
Referenced by fesa::ServerAction< DeviceType, DataType, FilterType >::execute(), fesa::DeviceFactoryImp< GlobalDeviceType, DomainStoreType, DevInstType >::initialize(), PersistencyManager(), fesa::AbstractServerController::start(), and start().
void fesa::PersistencyManager::registerPersistencyUnit | ( | PersistencyUnit * | pPersistencyUnit | ) |
this method adds a new persistence unit to the manager
pPersistencyUnit | the persistence unit that will be added |
Definition at line 32 of file PersistencyManager.cpp.
References fesa::GlobalDevice::className, fesa::ConfigFieldString::getAsString(), fesa::PersistencyUnit::getGlobalDevice(), and persistencyUnitsCol_.
void fesa::PersistencyManager::run | ( | ) | [protected, virtual] |
this method contains the logic of the persistent manager
Implements fesa::Thread.
Definition at line 97 of file PersistencyManager.cpp.
References accessMutex_, counterOfTriggers_, fesa::FesaException::getMessage(), fesa::Thread::hasFinished_, fesa::Thread::isRunning_, persistencyMaxDelay_, persistencySet_, fesa::StoreManager::store(), storeManager_, triggerCondVar_, and fesa::ConditionalVariable::wait().
void fesa::PersistencyManager::start | ( | ) |
starts the persistency process
FesaException |
Definition at line 63 of file PersistencyManager.cpp.
References fesa::AbstractEquipment::getDeviceDataFileName(), getInstance(), fesa::AbstractEquipment::getProcessConfiguration(), isStarted_, and fesa::Thread::setPriority().
Referenced by fesa::AbstractServerController::start().
void fesa::PersistencyManager::store | ( | PersistencyUnit & | pPersistencyUnit | ) | [protected] |
this method makes stores the information about the data stores contained in the persistent unit passed by parameter
pPersistencyUnit | containing the DataStore objects that will be stored |
void fesa::PersistencyManager::trigger | ( | const std::string & | className | ) |
this method triggers the store procedure that saves the persistent fields of the class passed as a parameter into the persistency file
className | name of the class from which the persistent fields will be stored |
Definition at line 82 of file PersistencyManager.cpp.
References accessMutex_, counterOfTriggers_, persistencySet_, persistencyUnitsCol_, fesa::ConditionalVariable::signal(), and triggerCondVar_.
Referenced by fesa::ServerAction< DeviceType, DataType, FilterType >::execute().
Mutex fesa::PersistencyManager::accessMutex_ [protected] |
mutex to protect the access to the persistent units
Definition at line 82 of file PersistencyManager.h.
uint32_t fesa::PersistencyManager::counterOfTriggers_ [protected] |
stores counters of persistent triggers The value is reset to zero when saving in a file. It is used to avoid that an avalanche of triggers produces a massive number of editions of the file.
Definition at line 120 of file PersistencyManager.h.
bool fesa::PersistencyManager::isStarted_ [protected] |
true if the persistent manager started
Definition at line 107 of file PersistencyManager.h.
Referenced by start().
uint32_t fesa::PersistencyManager::persistencyMaxDelay_ [protected] |
delay of the persistency mechanism, it is triggered after persistencyMaxDelay seconds
Definition at line 97 of file PersistencyManager.h.
Referenced by PersistencyManager(), and run().
std::set<PersistencyUnit*> fesa::PersistencyManager::persistencySet_ [protected] |
queue that stores the persistency units that have to be stored
Definition at line 92 of file PersistencyManager.h.
std::map<const std::string, PersistencyUnit*> fesa::PersistencyManager::persistencyUnitsCol_ [protected] |
this hasmap contains all the persistent units
Definition at line 87 of file PersistencyManager.h.
Referenced by registerPersistencyUnit(), trigger(), and ~PersistencyManager().
StoreManager fesa::PersistencyManager::storeManager_ [protected] |
stores the persistent units
Definition at line 112 of file PersistencyManager.h.
Referenced by run().
PersistencyManager * fesa::PersistencyManager::theInstance_ = NULL [static, protected] |
instance of the singleton object
Definition at line 58 of file PersistencyManager.h.
Referenced by getInstance().
conditional variable to trigger the persistency procedure
Definition at line 77 of file PersistencyManager.h.