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

Ref< T > Class Template Reference

Template whose instances are used as references to persistent objects. More...

#include <tRef.h>

Inheritance diagram for Ref< T >:

Inheritance graph
[legend]
Collaboration diagram for Ref< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

T * operator-> ()
T & operator * ()
 Ref ()
 Ref (const RefBase &Dbp)
 Ref (const Object *const DbObj)
 Ref (class Connection *aConnection, class ProtoBase *aPrototype, char *aSelectKeyValues, unsigned short aStrategies)
 Ref (class Connection *aConnection, const long anOid)
 Ref (class Connection *aConnection, const QueRefProto &aQuery)
 Ref (class Connection *aConnection, const char *aQuery)
Ref< T > & operator= (const RefBase &Dbp)
Ref< T > & operator= (const T *Ptr)
void setOID (const OidType oid, class Connection *connection)

Detailed Description

template<class T>
class Ref< T >

Template whose instances are used as references to persistent objects.

Instance of template Ref<T> can points to one object in one specific database. 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 were almost undocumented in POLiTe - I (Josef Troch) have commented it and made some changes to make multiple inheritance work and added methods to support persistence of attributes of this type.


Constructor & Destructor Documentation

template<class T>
Ref< T >::Ref  )  [inline]
 

Empty constructor - constructs DBNULL pointer.

template<class T>
Ref< T >::Ref const RefBase Dbp  )  [inline]
 

Copy constructor.

template<class T>
Ref< T >::Ref const Object *const  DbObj  )  [inline]
 

Constructor taking pointer to the object.

template<class T>
Ref< T >::Ref class Connection aConnection,
class ProtoBase aPrototype,
char *  aSelectKeyValues,
unsigned short  aStrategies
[inline]
 

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

template<class T>
Ref< T >::Ref class Connection aConnection,
const long  anOid
[inline]
 

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).

template<class T>
Ref< T >::Ref class Connection aConnection,
const QueRefProto aQuery
[inline]
 

Constructor that uses temporary query result to find object matching the query. Uses ExecuteQuery().

Note:
Rewritten by Josef Troch to suppress include dependency of Ref<T> on ProtoBase / ClassRegister.
Warning:
There can be only one object matching the query. If there are more such objects, created reference is DBNULL.
Parameters:
aConnection Connection to be used when sending query to database.
aQuery The query.

template<class T>
Ref< T >::Ref class Connection aConnection,
const char *  aQuery
[inline]
 

The same as Ref(class Connection *, const QueRefProto &), but query is given as string.


Member Function Documentation

template<class T>
T* Ref< T >::operator->  )  [inline]
 

Returns pointer to the referenced object. If the object is not present in memory yet, loads it from the database (using ObjectBuffer::GetReferencedObject()).

If reference points nowhere (DBNULL) throws ObjLibException_NotFound, if the referenced object cannot be cast to type T, throws IopcExceptionInvalidReference.

Note:
Rewritten by Josef Troch to support multiple inheritance - now uses dynamic_cast operator.

template<class T>
T& Ref< T >::operator *  )  [inline]
 

The same as operator->() but returns C++ reference to the object, not pointer.

template<class T>
Ref<T>& Ref< T >::operator= const RefBase Dbp  )  [inline]
 

Common operator =.

template<class T>
Ref<T>& Ref< T >::operator= const T *  Ptr  )  [inline]
 

Operator = that takes C++ pointer to object.

template<class T>
void Ref< T >::setOID const OidType  oid,
class Connection connection
[inline]
 

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.
connection The connection.
See also:
IopcPersistentObject::iopcImportAttributes(), getOID()


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