Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

IopcPersistentObject Class Reference

Abstract ancestor of all IOPC-style persistent objects. More...

#include <iopcPersistentObject.h>

Inheritance diagram for IopcPersistentObject:

Inheritance graph
[legend]
Collaboration diagram for IopcPersistentObject:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void iopcInitObject (bool loadingFromDB)=0
OidType getOID () const
bool IsDirty () const
bool MarkAsDirty ()
bool IsPersistent () const
bool IsTransient () const
bool Free ()
RefBase BePersistent (class Connection *connection)
bool Delete ()
bool Update ()
ProtoBasePrototype () const
RefBase operator & ()

Protected Member Functions

virtual int iopcImportAttributes (IopcImportExportStruct *data, int dataLen)=0
virtual int iopcExportAttributes (IopcImportExportStruct *data, int dataLen)=0
 IopcPersistentObject ()
virtual ~IopcPersistentObject ()
bool _MarkAsClean ()

Protected Attributes

IopcClassObjectm_classObject
bool m_isPersistent
bool m_isDirty
OidType m_oid

Detailed Description

Abstract ancestor of all IOPC-style persistent objects.

This class is parent of all persistent classes except old POLiTe-style persistent classes. (POLiTe-style persistent classes are ancestors of ImmutableObject, DatabaseObject or PersistentObject.)

Ancestors of this class have to implement this class's pure virtual functions and a few static functions. All these functions are generated when processing user source files by IOPC SP.


Constructor & Destructor Documentation

IopcPersistentObject::IopcPersistentObject  )  [inline, protected]
 

Simple constructor

Note:
Method iopcInitObject() cannot be called there - it would call iopcInitObject() of IopcPersistentObject not ancestor's one (although iopcInitObject() is virtual).

virtual IopcPersistentObject::~IopcPersistentObject  )  [inline, protected, virtual]
 

Empty destructor.

Note:
Free() cannot be called there because it may result into persistent object update and this update needs object's virtual function iopcExportAttributes(), but mechanism of virtual functions doesn't work in destructor.

That's why call of Free() is added by IOPC SP to each persistent class's destructor.


Member Function Documentation

virtual void IopcPersistentObject::iopcInitObject bool  loadingFromDB  )  [pure virtual]
 

Initializes flags that says which attributes of current instance are valid.

If loadingFromDB is set, sets values of all the flags to 0, otherwise to 1. If loadingFromDB is not set it also sets the value of m_classObject.

This function is implemented in each ancestor of this class - its code is generated by IOPC SP.

The function is called when loading persistent object from DB to memory and when BePersistent() is called on a transient object.

virtual int IopcPersistentObject::iopcImportAttributes IopcImportExportStruct data,
int  dataLen
[protected, pure virtual]
 

Sets object attributes according to values in array data. Used when loading object attributes from the database.

See IopcImportExportStruct and IopcClassObjectImpl::importExportArray for further information.

This function is implemented in each ancestor of this class - its code is generated by IOPC SP.

Parameters:
data Array of structs containing data for individual attributes.
dataLen Length of array data.
Returns:
0 if OK, non-zero in case of error.
See also:
iopcExportAttributes()

virtual int IopcPersistentObject::iopcExportAttributes IopcImportExportStruct data,
int  dataLen
[protected, pure virtual]
 

Fills object attributes into the array data. Used when saving object attributes to the database.

See IopcImportExportStruct and IopcClassObjectImpl::importExportArray for further information.

This function is implemented in each ancestor of this class - its code is generated by IOPC SP.

Parameters:
data Array of structs into which attribute values should be filled in.
dataLen Length of array data.
Returns:
0 if OK, non-zero in case of error.
See also:
iopcImportAttributes()

OidType IopcPersistentObject::getOID  )  const [inline]
 

Returns object's OID

See also:
m_oid

bool IopcPersistentObject::IsDirty  )  const [inline, virtual]
 

Returns true, if the object is marked as dirty (i.e. the object was changed in the memory).

See also:
m_isDirty, MarkAsDirty(), _MarkAsClean()

Reimplemented from Object.

bool IopcPersistentObject::MarkAsDirty  )  [inline, virtual]
 

Marks the persistent object as dirty.

Note:
Only dirty (changed) objects are written to the database when flushing the object cache.
See also:
m_isDirty, IsDirty(), _MarkAsClean()

Reimplemented from Object.

bool IopcPersistentObject::IsPersistent  )  const [inline, virtual]
 

Returns true if the object is persistent, false otherwise.

See also:
m_isPersistent, IsTransient()

Reimplemented from Object.

bool IopcPersistentObject::IsTransient  )  const [inline, virtual]
 

Returns true if the object is transient, false otherwise.

See also:
m_isPersistent, IsPersistent()

Reimplemented from Object.

bool IopcPersistentObject::Free  )  [inline, virtual]
 

Removes the referenced object from memory only

Returns:
true if OK, false in case of error (f.e. if the object is locked in memory).
See also:
ObjectBuffer

Reimplemented from Object.

RefBase IopcPersistentObject::BePersistent class Connection connection  )  [virtual]
 

Makes the object persistent (if it was transient).

Initializes object's persistence flags (iopcInitObject()), inserts it into the database (IopcClassObject::insertObject()) and registers it in object cache (ObjectBuffer::RegisterObject()).

Parameters:
connection Connection to be used when inserting the object into the database.
Returns:
Reference to the object.

Reimplemented from Object.

bool IopcPersistentObject::Delete  )  [virtual]
 

Removes the referenced object both from the memory and from the database.

Returns:
true if OK, false in case of error (f.e. if the object is locked).
See also:
IopcClassObject::deleteObject(), ObjectBuffer

Reimplemented from Object.

bool IopcPersistentObject::Update  )  [virtual]
 

Writes the object from the memory to the database.

Does nothing if the object is not persistent or not dirty.

Returns:
true if OK, false in case of error.
See also:
IopcClassObject::updateObject()

Reimplemented from Object.

ProtoBase * IopcPersistentObject::Prototype  )  const [virtual]
 

Returns IopcProtoBaseAdaptor that corresponds to m_classObject. Used by old POLiTe classes.

Warning:
Although this method is public, user should NEVER call it. If called the function returns pointer to IopcProtoBaseAdaptor object. This object doesn't "correctly" implement all functions described in old POLiTe user reference.
The only case when user can use acquired prototype is if he wants to use it as a query - to get all instances of a persistent class.

Implements ObjRef.

RefBase IopcPersistentObject::operator &  ) 
 

Returns Ref<T> reference to the object.

bool IopcPersistentObject::_MarkAsClean  )  [inline, protected, virtual]
 

Marks the persistent object as clean (not changed).

Note:
Only dirty (changed) objects are written to the database when flushing the object cache.
See also:
m_isDirty, IsDirty(), MarkAsDirty().

Reimplemented from Object.


Member Data Documentation

IopcClassObject* IopcPersistentObject::m_classObject [protected]
 

Pointer to IopcClassObjectImpl that represents persistent object's class. Set in IopcPersistentObject::iopcInitObject() or IopcClassObjectImpl::loadObject().

bool IopcPersistentObject::m_isPersistent [protected]
 

Is this instance persistent?

bool IopcPersistentObject::m_isDirty [protected]
 

Is the object dirty? (Has it been changed?).

OidType IopcPersistentObject::m_oid [protected]
 

Object ID - unique identifier of persistent object instance.


The documentation for this class was generated from the following files:
Generated on Wed Aug 11 22:35:38 2004 for IOPC by Doxygen 1.3.6