API Guides > ConceptRT 3.x
SyncPersistenceController Class Reference

Persistence controller for simple variable. More...

Detailed Description

Persistence controller for simple variable.

The data synchronization is handle by a SynchronThreadGroup.

Note
Multiple SyncPersistenceController can be created, each one beeing synchronized with a different SynchronThreadGroup
RT Exceptions:
RT_ERROR_SYNC_PERSISTENT_NOT_ABLE_OPEN_FILE

RT_ERROR_SYNC_PERSISTENT_NOT_ABLE_OPEN_FILE is only shown through GetLastExceptionMessage()

Public Member Methods

 SyncPersistenceController ()
 Constructor. More...
 
 ~SyncPersistenceController ()
 Destructor. More...
 
void Start (SynchronThreadGroup &group, PCChar8 persistenceSubFolderName=NULL)
 Start the persistence controller. More...
 
void RequestTerminate ()
 Request the controller for terminate. More...
 
bool WaitTerminated (TimeSpan timeout=TimeInfinite)
 Wait for the controller to terminate. More...
 
template<class T >
void Register (PCChar8 persistenceName, T &data)
 Register a variable to persiste More...
 
void Unregister (PCChar8 persistenceName)
 Unregister a variable to persiste More...
 
bool HasUnsafeData ()
 Query if there are unsafe data. More...
 
void ClearHasUnsafeData ()
 Clear the unsafe data flag. More...
 
bool HasException ()
 Query if there are exception that occured in the controller. More...
 
const StringGetLastExceptionMessage ()
 Gets the message exception that occured in the controller. More...
 
void ClearHasException ()
 Clear the exception flag. More...
 
StringsGetDiagnostics ()
 Gets the diagnostic messages given by the controller when Register variables. More...
 

Constructor & Destructor Documentation

Constructor.

Destructor.

Wait thread for terminate.

Methods Documentation

void ClearHasException ( )

Clear the exception flag.

void ClearHasUnsafeData ( )

Clear the unsafe data flag.

Strings& GetDiagnostics ( )

Gets the diagnostic messages given by the controller when Register variables.

Returns
The diagnostic messages
const String& GetLastExceptionMessage ( )

Gets the message exception that occured in the controller.

Returns
The last exception message
bool HasException ( )

Query if there are exception that occured in the controller.

Returns
true if there are, false if not.
bool HasUnsafeData ( )

Query if there are unsafe data.

Returns
true if there is unsafe data, false if not.

Unsafe data are detected whenever the controller has not been stopped properly once. (Crash or programming fault).

void Register ( PCChar8  persistenceName,
T &  data 
)
inline

Register a variable to persiste

Parameters
persistenceNameVariable identifiant. Should be unique in a controller.
datathe variable.
Warning
Call order dependence : Start() should be called before Register
RT Exceptions:
RT_ERROR_SYNC_PERSISTENT_CONTROLLER_NOT_STARTED
void RequestTerminate ( )

Request the controller for terminate.

void Start ( SynchronThreadGroup group,
PCChar8  persistenceSubFolderName = NULL 
)

Start the persistence controller.

Parameters
group[in, out] The SynchronThreadGroup used for the concurrent data access synchronization.
persistenceSubFolderName[in] The persistence Sub Folder Name in the GetPersistencePath() directory.
Warning
Call order dependence : Start should be called before Register()
RT Exceptions:

RT_ERROR_SYNC_PERSISTENT_CONTROLLER_ALREADY_STARTED

RT_ERROR_SYNC_PERSISTENT_NOT_ABLE_CREATE_DIR

void Unregister ( PCChar8  persistenceName)

Unregister a variable to persiste

Parameters
persistenceNameVariable identifiant.
bool WaitTerminated ( TimeSpan  timeout = TimeInfinite)

Wait for the controller to terminate.

Parameters
timeout(optional) the time out. Default = TimeInfinite
Returns
true if it succeeds, false if a timeout occurs.