ACF $AcfVersion:0$
Public Types | Public Member Functions | Protected Member Functions | List of all members
ifile::CAutoPersistenceComp Class Reference

The component for automatic object persistence. More...

#include <CAutoPersistenceComp.h>

Inheritance diagram for ifile::CAutoPersistenceComp:
ilog::TLoggerCompWrap< Base > imod::CMultiModelDispatcherBase ilog::CLoggerBase istd::IPolymorphic ilog::ILoggable istd::ILogger istd::IPolymorphic istd::IPolymorphic

Public Types

enum  ModelIds { MI_OBJECT , MI_FILEPATH , MI_RUNTIME_STATUS }
 
typedef ilog::CLoggerComponentBase BaseClass
 
typedef imod::CMultiModelDispatcherBase BaseClass2
 
- Public Types inherited from ilog::TLoggerCompWrap< Base >
typedef Base BaseClass
 Base class typedef for component functionality.
 
typedef ilog::CLoggerBase BaseClass2
 Base class typedef for logger functionality.
 

Public Member Functions

 CAutoPersistenceComp ()
 Default constructor.
 
- Public Member Functions inherited from ilog::CLoggerBase
 CLoggerBase ()
 Default constructor.
 
virtual void SetLogPtr (ilog::IMessageConsumer *logPtr) override
 Attach a message consumer for logging.
 
virtual ilog::IMessageConsumerGetLogPtr () const override
 Get the currently attached message consumer.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Protected Member Functions

void SaveObjectSnapshot ()
 Store object copy in a separate thread.
 
virtual bool LoadObject (const QString &filePath)
 Load working object data from some file.
 
virtual bool StoreObject (const istd::IChangeable &object)
 Store some object data to working file.
 
virtual void OnComponentCreated () override
 Called when component is created.
 
virtual void OnComponentDestroyed () override
 Called when component is destroyed.
 
virtual void OnModelChanged (int modelId, const istd::IChangeable::ChangeSet &changeSet) override
 Called when some model observed by dispatcher will be changed.
 
- Protected Member Functions inherited from ilog::TLoggerCompWrap< Base >
bool IsVerboseEnabled (int tracingLevel=0) const
 Check if verbose messages are enabled for a given tracing level.
 
void SendVerboseMessage (const QString &message, const QString &messageSource=QString(), int tracingLevel=0) const
 Send a verbose message if enabled.
 
virtual void DecorateMessage (istd::IInformationProvider::InformationCategory category, int id, int flags, QString &message, QString &messageSource) const override
 Decorate message before sending.
 
- Protected Member Functions inherited from ilog::CLoggerBase
bool SendInfoMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send info message to log.
 
bool SendWarningMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send warning message to log.
 
bool SendErrorMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send error message to log.
 
bool SendCriticalMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send critical message to log.
 
bool SendInfoMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once info message to log.
 
bool SendWarningMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once warning message to log.
 
bool SendErrorMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once error message to log.
 
bool SendCriticalMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once critical message to log.
 
bool SendUserMessage (const istd::IInformationProvider *messagePtr) const
 Send message with user object.
 
bool AllowMessageOnceAgain (int id)
 Reset message lock.
 
virtual bool IsLogConsumed (const istd::IInformationProvider::InformationCategory *categoryPtr=NULL, const int *flagsPtr=NULL) const override
 Check if any log message is consumed.
 
virtual bool SendLogMessage (istd::IInformationProvider::InformationCategory category, int id, const QString &message, const QString &messageSource, int flags=0) const override
 Send any message to log.
 
bool RegisterModel (IModel *modelPtr, int modelId=0, const istd::IChangeable::ChangeSet &relevantFlags=istd::IChangeable::GetAllChanges())
 Register the data model to be observed.
 
void UnregisterModel (int modelId=0)
 Unregister the data model object.
 
void UnregisterAllModels ()
 Unregister all observed data objects.
 
template<class Object >
Object * GetObjectAt (int modelId) const
 Get concrete object instance of the obsered model.
 

Additional Inherited Members

- Protected Attributes inherited from ilog::CLoggerBase
QSet< int > m_onceMessageIds
 

Detailed Description

The component for automatic object persistence.

With the help of this component data objects can be backed up at specific time points and restored. The data object that should be restored or backed up, will be connected via component reference. The backup or restoring of data is done according to the component configuration, that is given by the component's attributes. Enable RestoreOnBegin attribute if you want to restore the object from the file during component initialization. Enable StoreOnEnd attribute if you want to save the object to the file during component de-initialization. Enable StoreOnChange attribute if you want to save the object to the file each time if the object data was changed. Also you can specify some time interval for permanently data storing. If this parameter is set, then the object will be stored to the file in the given time interval, but only if the object data was changed.

Note
If the time interval for the object storing is set, the StoreOnChange attribute will be ignored.
Please note, that this component doesn't provide any public interfaces. The data object will be attached to the internal observer during the initialization phase of the component. To enforce the instantiation of this component, you should activate 'Automatically create instance' flag in the Compositor.

Definition at line 44 of file CAutoPersistenceComp.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 52 of file CAutoPersistenceComp.h.

◆ BaseClass2

Definition at line 53 of file CAutoPersistenceComp.h.

Member Enumeration Documentation

◆ ModelIds

Enumerator
MI_OBJECT 

Object was changed.

MI_FILEPATH 

File path was changed.

MI_RUNTIME_STATUS 

Runtime status was changed.

Definition at line 55 of file CAutoPersistenceComp.h.

Constructor & Destructor Documentation

◆ CAutoPersistenceComp()

ifile::CAutoPersistenceComp::CAutoPersistenceComp ( )

Default constructor.

Member Function Documentation

◆ LoadObject()

virtual bool ifile::CAutoPersistenceComp::LoadObject ( const QString &  filePath)
protectedvirtual

Load working object data from some file.

◆ OnComponentCreated()

virtual void ifile::CAutoPersistenceComp::OnComponentCreated ( )
overrideprotectedvirtual

Called when component is created.

Automatically connects the log consumer from the "Log" reference.

Note
Override to add initialization, but always call base class:
virtual void OnComponentCreated() override {
// Custom initialization
}
virtual void OnComponentCreated() override
Called when component is created.
virtual void OnComponentCreated() override
Called when component is created.

Reimplemented from ilog::TLoggerCompWrap< Base >.

◆ OnComponentDestroyed()

virtual void ifile::CAutoPersistenceComp::OnComponentDestroyed ( )
overrideprotectedvirtual

Called when component is destroyed.

Automatically disconnects the log consumer for cleanup.

Note
Override to add cleanup, but always call base class:
virtual void OnComponentDestroyed() override {
// Custom cleanup
}
virtual void OnComponentDestroyed() override
Called when component is destroyed.
virtual void OnComponentDestroyed() override
Called when component is destroyed.

Reimplemented from ilog::TLoggerCompWrap< Base >.

◆ OnModelChanged()

virtual void ifile::CAutoPersistenceComp::OnModelChanged ( int  modelId,
const istd::IChangeable::ChangeSet changeSet 
)
overrideprotectedvirtual

Called when some model observed by dispatcher will be changed.

Implements imod::CMultiModelDispatcherBase.

◆ SaveObjectSnapshot()

void ifile::CAutoPersistenceComp::SaveObjectSnapshot ( )
protected

Store object copy in a separate thread.

◆ StoreObject()

virtual bool ifile::CAutoPersistenceComp::StoreObject ( const istd::IChangeable object)
protectedvirtual

Store some object data to working file.


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