Storeable Class Reference
[Public API]

Class that defines objects storeable in Archive using obiject ouytput streams and loadable from Archive using object input streams. More...

#include <storeable.h>

Collaboration diagram for Storeable:

Collaboration graph
[legend]
List of all members.

Public Types

enum  stState { NEW, CHANGED, DELETED, OK }
 state of storeable object More...

Public Member Functions

id getId () const
 get object id
const char * getRootTable ()
 get name of root table
stState getState () const
 get object state
bool isChanged () const
 Check if object is in CHANGED state.
bool isDeleted () const
 Check if object is in DELETED state.
bool isNew () const
 Check if object is in NEW state.
bool isOk () const
 Check if object is in OK state.
virtual void lockStid (bool pPreserveState)
 Lock id.
Storeableoperator= (const Storeable &pObj)
 Assignent operator.
void setChanged ()
 set object state to CHANGED
void setDeleted ()
 set object state to DELETED
void setId (id pId)
 assingn id by hand.
template<typename T>
bool setMember (T &pMember, const T &pNevVal)
 helper function to set member of Storeable derived object.
virtual void setNew ()
 set object to NEW state, reset Id and mStoredTables
void setOk ()
 set object state to OK
virtual void setState (stState pState)
 Set new object state.
 Storeable (const Storeable &pObj)
 Copy constructor.
 Storeable (id pId=InvalidId)
 Create new object with id.
virtual void unlockStid ()
 Unlock state and id of object for copy constructor and assigment operator.
virtual ~Storeable ()
 Destructor.

Static Public Attributes

static const Storeable *const dba_pointer_place
 Internal pointer for computing offsets corrections in case of multiple inheritance.
static const id InvalidId
 id of object that was now stored in database.
static StoreTableList sStoreTableList
 Static list of created tables Responsible for freeing all memory allocated by BEGIN_STORE_TABLE macro.

Protected Types

enum  lock_state { UNLOCKED, LOCKED, LOCKED_PRESERVE_STATE }
 state of lock on object data for assigment operator and copy constructor More...

Protected Member Functions

int countTables ()
 Get number.
void normalAssigment (const Storeable &pObj)
 Variant of assigment operator.
void preserveIdAssigment (const Storeable &pObj)
 Variant of assigment operator.
virtual const ColTable * st_getColTable ()
 Get collection table list for object.
virtual const StoreTable * st_getTable ()
 Get store table list for object.

Protected Attributes

id mId
 id of object
lock_state mIdLocked
 Lock state.
int mStoredTables
 number of tables from first one that are already stored for object
stState mStoreState
 Store state.

Classes

class  StidLocker
 Helper class for locking Storeable data when doing Archive operations. More...

Detailed Description

Class that defines objects storeable in Archive using obiject ouytput streams and loadable from Archive using object input streams.

Derived classes must provide default constructor and copy constructor.


Member Enumeration Documentation

enum lock_state [protected]
 

state of lock on object data for assigment operator and copy constructor

Enumerator:
LOCKED  state and id is copied
LOCKED_PRESERVE_STATE  state and id is preserved

enum stState
 

state of storeable object

Enumerator:
NEW  object is newly created. Sync() will insert it into database
CHANGED  object was changed since last sync()
DELETED  object is deleted. sync() will delete it from database
OK  object is not changed since last sync()

Constructor & Destructor Documentation

Storeable id  pId = InvalidId  ) 
 

Create new object with id.

Parameters:
pId id of object or InvalidId if unknown

Storeable const Storeable pObj  ) 
 

Copy constructor.

Copies object state if no IdLocker is constructed.

Parameters:
pObj object to copy from

Member Function Documentation

id getId  )  const
 

get object id

Returns:
object id

const char* getRootTable  ) 
 

get name of root table

Returns:
pointer to root table name or NULL if root table name is not set

stState getState  )  const
 

get object state

See also:
stState

bool isChanged  )  const
 

Check if object is in CHANGED state.

Returns:
true if object is in CHANGED state or false otherwise

bool isDeleted  )  const
 

Check if object is in DELETED state.

Returns:
true if object is in DELETED state or false otherwise

bool isNew  )  const
 

Check if object is in NEW state.

Returns:
true if object is in NEW state or false otherwise

bool isOk  )  const
 

Check if object is in OK state.

Returns:
true if object is in OK state or false otherwise

virtual void lockStid bool  pPreserveState  )  [virtual]
 

Lock id.

Used by StidLocker to lock object id before assigment.

Parameters:
pPreserveState if true then lock state but not id, otherwise lock both state and id

void normalAssigment const Storeable pObj  )  [protected]
 

Variant of assigment operator.

Copies state.

Parameters:
pObj object to copy from

Storeable& operator= const Storeable pObj  ) 
 

Assignent operator.

Copies object state if no IdLocker is constructed.

Parameters:
pObj object to copy from

void preserveIdAssigment const Storeable pObj  )  [protected]
 

Variant of assigment operator.

Calls setChanged()

Parameters:
pObj not used

void setChanged  ) 
 

set object state to CHANGED

See also:
stState

void setDeleted  ) 
 

set object state to DELETED

See also:
stState

void setId id  pId  ) 
 

assingn id by hand.

Allowed only if getId() == InvalidId

Warning:
Do not use this method unless you really know what you are doing. If you want clone Storeable object use IdLocker instead.
Parameters:
pId new id

bool setMember T &  pMember,
const T &  pNewVal
 

helper function to set member of Storeable derived object.

It changes state of object to CHANGED if new value is different from old value

Parameters:
pMember member value
pNewVal new value
Returns:
true if member was set or false otherwise

void setOk  ) 
 

set object state to OK

See also:
stState

Member Data Documentation

const id InvalidId [static]
 

id of object that was now stored in database.


If object has this id it means that id was never assigned


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

Documentation
Quick start
Examples
Search

API Documentation
Class hierarchy
Member index
API Reference
Store filters
Store table macros
Back

Generated by doxygen at Sun Nov 9 02:08:30 2008