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

RefBase Class Reference

Abstract class representing reference to a persistent object. More...

#include <cRefBase.h>

Inheritance diagram for RefBase:

Inheritance graph
[legend]
Collaboration diagram for RefBase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RefBase ()
 RefBase (const RefBase &Dbp)
 RefBase (const Object *const DbObj)
 RefBase (class Connection *aConnection, class ProtoBase *aPrototype, char *aSelectKeyValues, unsigned short aStrategies)
 RefBase (class Connection *aConnection, class ProtoBase *aPrototype, const OidType oid, unsigned short aStrategies)
 RefBase (class Connection *aConnection, ObjectIdentification *anIdentification)
 RefBase (class Connection *aConnection, const long anOid, class ProtoBase *aPrototype)
virtual ~RefBase ()
virtual bool Init (class Connection *aConnection, class ProtoBase *aPrototype, char *aSelectKeyValues)
virtual ObjectReferencedObject () const
ObjectIsInMemory () const
ObjectIdentification ObjectID () const
virtual class ProtoBasePrototype () const
virtual bool IsDirty () const
virtual bool MarkAsDirty ()
virtual bool Refresh ()
virtual bool Update ()
virtual bool Free ()
virtual bool Delete ()
ObjectMemoryLock ()
bool MemoryUnlock ()
virtual unsigned int MemoryLocked () const
virtual bool RemoveAllMemoryLocks ()
virtual class RefBase BePersistent (class Connection *DbCon)
bool operator== (const class RefBase &DbPtr) const
bool operator!= (const class RefBase &DbPtr) const
ResultBaseExecuteQuery (const char *className, const QueRefProto &query, class Connection *connection, ResultBase *result)
OidType getOID () const

Protected Member Functions

virtual class Object_Object ()
virtual class RefBase_Virtualise ()
virtual char * _KeyValues () const
virtual bool _MarkAsClean ()
virtual bool _Free ()
void setOID (const OidType oid, const char *className, class Connection *connection)

Protected Attributes

ObjectIdentification _ObjectIdentification

Detailed Description

Abstract class representing reference to a persistent object.

RefBase descendants, instances of template Ref<T> are used as references to persistent objects. The descendant can points to one object in one specific database, thus RefBase contains both _Connection and _ObjectIdentification.

When accessing the object, the reference is automatically dereferenced and the object is retrieved (if necessary) from database and placed into the memory. To minimise the amount of database accesses all persistent objects contained currently in memory are registered in the library persistent objects cache - ObjectCache.

Objects of type Ref<T> can be used as persistent attributes in IOPC-style persistent objects (IopcPersistentObject descendants), see getOID() and setOID().

This class was partially documented in POLiTe - I (Josef Troch) have put the comments from source files to doxygen, extended them and commented what wasn't commented. I have also commented the new methods I had added.


Constructor & Destructor Documentation

RefBase::RefBase  ) 
 

Empty constructor - constructs DBNULL pointer.

RefBase::RefBase const RefBase Dbp  ) 
 

Copy constructor.

RefBase::RefBase const Object *const  DbObj  ) 
 

Constructor taking pointer to the object.

RefBase::RefBase class Connection aConnection,
class ProtoBase aPrototype,
char *  aSelectKeyValues,
unsigned short  aStrategies
 

Constructor taking object's connection, prototype, encoded key values (aSelectKeyValues) and locking/waiting strategies.

RefBase::RefBase class Connection aConnection,
class ProtoBase aPrototype,
const OidType  oid,
unsigned short  aStrategies
 

New constructor added by Josef Troch. Takes object's connection, prototype, OID and locking/waiting strategies.

RefBase::RefBase class Connection aConnection,
ObjectIdentification anIdentification
 

Constructor that takes object's connection and identification.

RefBase::RefBase class Connection aConnection,
const long  anOid,
class ProtoBase aPrototype
 

Old constructor (POLiTe-style) that takes object's connection, OID and prototype. This constructor encodes the OID to get string, doesn't uses OID directly (see ObjectIdentification).

RefBase::~RefBase  )  [virtual]
 

Destructor.


Member Function Documentation

bool RefBase::Init class Connection aConnection,
class ProtoBase aPrototype,
char *  aSelectKeyValues
[virtual]
 

Reinitializes already existing reference - takes connection, prototype and encoded key values (aSelectKeyValues).

virtual class Object* RefBase::_Object  )  [inline, protected, virtual]
 

Returns pointer to object stored in the _ObjectIdentification.

class RefBase & RefBase::_Virtualise  )  [protected, virtual]
 

Typecasts RefBase to class A to RefBase to correct A's subclass B. Does nothing in other derived classes.

Note:
Used only for POLiTe-style persistent classes. Polymorphism of queries and references in IOPC system is implemented in Prototype().

char * RefBase::_KeyValues  )  const [protected, virtual]
 

Returns pointed object's encoded key values (NULL for IopcPersistentObject descendants).

Implements ObjRef.

Object & RefBase::ReferencedObject  )  const [virtual]
 

Returns C++ reference to the pointed object. The object is read from the database, if the object is not present in memory yet.

Object * RefBase::IsInMemory  )  const [virtual]
 

Test whether referenced object is in memory. If so, returns pointer to it, if not, returns NULL.

Implements ObjRef.

ObjectIdentification RefBase::ObjectID  )  const [virtual]
 

Returns object identification.

Implements ObjRef.

class ProtoBase * RefBase::Prototype  )  const [virtual]
 

Returns a reference to the prototype of the referenced class.

If the reference points to IopcPersistentObject descendant and ObjectIdentification::_prototype is NULL, calls IopcClassObjectImpl::getClassIDForOid() and IopcClassObjectContainer::getClassObjectFromClassID() to load class's Class ID from database and convert it to IopcClassObjectImpl / IopcProtoBaseAdaptor.

Implements ObjRef.

bool RefBase::IsDirty  )  const [virtual]
 

Returns true, if the object is marked as dirty (i.e. the object was changed in the memory). Calls the same named method on referenced object.

See also:
MarkAsDirty(), _MarkAsClean(), IopcPersistentObject::IsDirty()

Implements ObjRef.

bool RefBase::MarkAsDirty  )  [virtual]
 

Marks the persistent object as dirty. Calls the same named method on referenced object.

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

Implements ObjRef.

bool RefBase::_MarkAsClean  )  [protected, virtual]
 

Marks the persistent object as clean (not changed). Calls the same named method on referenced object.

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

Implements ObjRef.

bool RefBase::Refresh  )  [virtual]
 

Refreshes the object in memory - loads it from database to memory again.

Returns:
true if OK, false in case of error.

Implements ObjRef.

bool RefBase::Update  )  [virtual]
 

Writes the referenced object from the memory to the database.

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

Implements ObjRef.

bool RefBase::Free  )  [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).

Implements ObjRef.

bool RefBase::_Free  )  [protected, virtual]
 

Removes the referenced object from memory only. The same as Free().

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

Implements ObjRef.

bool RefBase::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).

Implements ObjRef.

Object * RefBase::MemoryLock  )  [virtual]
 

Locks a persistent object. Multiple locks can be placed on the object. The object can be removed from memory only when all the locks are released.

Implements ObjRef.

bool RefBase::MemoryUnlock  )  [virtual]
 

Unlocks a persistent object in memory. See MemoryLock().

Implements ObjRef.

unsigned int RefBase::MemoryLocked  )  const [virtual]
 

Returns the number of memory locks on referenced object or zero if it is not locked.

Implements ObjRef.

bool RefBase::RemoveAllMemoryLocks  )  [virtual]
 

Removes all memory locks on the referenced object.

Reimplemented from ObjRef.

RefBase RefBase::BePersistent class Connection DbCon  )  [virtual]
 

Makes the object persistent (if it was transient).

This function didn't do anything in POLiTe. I (Josef Troch) think it is a bug, but I retained this behaviour for POLiTe-style persistent objects. For IopcPersistentObject ancestors it calls BePersistent() on the referenced object (if the object was transient).

Parameters:
DbCon Connection to be used when saving the object.
Returns:
This object.

Implements ObjRef.

bool RefBase::operator== const class RefBase DbPtr  )  const
 

Tests whether the two references reference the same object.

Reimplemented in ResultBase.

bool RefBase::operator!= const class RefBase DbPtr  )  const
 

Tests whether the two referenced objects are different.

Reimplemented in ResultBase.

ResultBase * RefBase::ExecuteQuery const char *  className,
const QueRefProto query,
class Connection connection,
ResultBase result
 

Executes given query.

Added by Josef Troch to suppress include dependency of Ref<T> on ProtoBase / ClassRegister.

Executes query on className's class prototype (Proto<T> / IopcProtoBaseAdaptor). Gets the prototype and calls function with the same name on it.

Called from Ref<T>::Ref(class Connection *, const char *).

Parameters:
className Name of class, whose prototype should be used.
query The query.
connection Connection to be used for query processing.
result Object into which identification of acquired objects should be placed.
Returns:
Parameter result.

OidType RefBase::getOID  )  const
 

If the referenced object is IopcPersistentObject descendant, returns OID of the referenced object.

This function was added by Josef Troch to support persistence of attributes of type Ref<T>. It is called from persistent object's iopcExportAttributes() function.

Returns:
OID, 0 if the object is not persistent or not IopcPersistentObject descendant.
See also:
IopcPersistentObject::iopcExportAttributes(), setOID()

void RefBase::setOID const OidType  oid,
const char *  className,
class Connection connection
[protected]
 

Sets _ObjectIdentification and _Connection to point to object with OID oid, receivable through connection connection.

This function was added by Josef Troch to support persistence of attributes of type Ref<T>. It is called from persistent object's iopcImportAttributes() function.

Parameters:
oid The OID.
className Name of object's class. Not used for now.
connection The connection.
See also:
IopcPersistentObject::iopcImportAttributes(), getOID()


Member Data Documentation

class ObjectIdentification RefBase::_ObjectIdentification [protected]
 

Object identification, see RefBase class description.


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