BankAndCustomer
Loading...
Searching...
No Matches
glo::TOndemand< T > Class Template Reference

A reference (as attribute) of a persistent object to another persistent object in the database. More...

#include <GloTOndemand.h>

Inheritance diagram for glo::TOndemand< T >:
Collaboration diagram for glo::TOndemand< T >:

Public Member Functions

 TOndemand ()
 
 TOndemand (const ObjID &rObjID)
 
 TOndemand (Base &rBase)
 
 TOndemand (unsigned long ulDatabaseID)
 
 TOndemand (const ObjID &rObjID, Base &rBase)
 
 TOndemand (const ObjID &rObjID, unsigned long ulDatabaseID)
 
 TOndemand (const TOndemand &rT)
 
virtual ~TOndemand ()
 
int set (const T *pObj)
 
int set (const T &rObj)
 
int set (const std::shared_ptr< T > &spObj)
 
int get (T *&prObj)
 
int get (std::shared_ptr< T > &rRetVal)
 
virtual int setReference (const ObjID &rObjID) override
 
TOndemand< T > & operator= (const TOndemand &rT)
 Assignment operator.
 
TOndemand< T > & operator= (const Reference &rT)
 Assignment operator.
 
bool operator== (const TOndemand &rT) const
 Comparison operator.
 
bool operator!= (const TOndemand &rT) const
 Comparison operator.
 
- Public Member Functions inherited from glo::Reference
 Reference ()
 
 Reference (const ObjID &rObjID)
 
 Reference (Base &rBase)
 
 Reference (unsigned long ulDatabaseID)
 
 Reference (const ObjID &rObjID, Base &rBase)
 
 Reference (const ObjID &rObjID, unsigned long ulDatabaseID)
 
 Reference (const Reference &rT)
 
virtual ~Reference ()
 
virtual int setBase (Base *pBase) override
 
virtual BasegetBase () const override
 
virtual int getTypeAsString (std::string &rsTypeName) override
 
bool isNULL () const
 
void setNULL ()
 
ObjID getObjID () const
 
const ObjIDgetObjIDAsPointer () const
 
int setReference (const BasePersistent *pObj)
 
int setReference (const BasePersistent &rObj)
 
int getReference (BasePersistent *&prRetVal)
 
int getReference (std::shared_ptr< BasePersistent > &sprRetVal)
 
virtual int deleteInBase (EnDeepMode eDeepMode=DM_SHALLOW)
 
virtual int lock (EnLockMode eLockMode=LK_DELETEvWRITE, EnDeepMode eDeepMode=DM_SHALLOW) const
 
virtual int lock (const LockSpecification &rLockSpecification) const
 
virtual int unlock (EnLockMode eLockMode=LK_DELETEvWRITE, EnDeepMode eDeepMode=DM_SHALLOW) const
 
virtual int unlock (const LockSpecification &rLockSpecification) const
 
virtual int isLocked (EnLockMode eLockMode=LK_DELETEvWRITE, EnDeepMode eDeepMode=DM_SHALLOW) const
 
virtual int isLocked (const LockSpecification &rLockSpecification) const
 
virtual int isPossible (bool bRead, bool bWrite, bool bDelete, EnDeepMode eDeepMode=DM_SHALLOW) const
 
virtual int isPossible (const LockPossibleSpecification &rLockPossibleSpec, EnDeepMode eDeepMode=DM_SHALLOW) const
 
virtual int setWatch (TdWatchNotifyMode ulWatchMode, EnDeepMode eDeepMode, CallBack *pCallBack=0) const
 
virtual int setWatch (const WatchSpecification &rWatchSpec) const
 
virtual int unsetWatch (TdWatchNotifyMode ulWatchMode, EnDeepMode eDeepMode, CallBack *pCallBack) const
 
virtual int unsetWatch (const WatchSpecification &rWatchSpec) const
 
Referenceoperator= (const Reference &rT)
 
bool operator== (const Reference &rT) const
 Comparison operator.
 
bool operator!= (const Reference &rT) const
 Comparison operator.
 
- Public Member Functions inherited from glo::CallBack
 CallBack ()
 
virtual ~CallBack ()
 
virtual void notify (NotifyNote &rNote)
 
CallBackoperator= (const CallBack &rT)
 
bool operator== (const CallBack &rT) const
 Comparison operator, all attributes are compared.
 
bool operator!= (const CallBack &rT) const
 Comparison operator, all attributes are compared.
 

Additional Inherited Members

- Public Attributes inherited from glo::CallBack
std::string m_strDebugInfo
 
- Protected Member Functions inherited from glo::CallBack
 CallBack (const CallBack &rT)
 
void init ()
 
void deinit ()
 

Detailed Description

template<class T>
class glo::TOndemand< T >

A reference (as attribute) of a persistent object to another persistent object in the database.

In contrast to a pointer to a persistent object (where the referenced object is loaded with the referencing object), TOndemand is a reference to a persistent object via the object ID; it is not loaded with the referencing object from the database, but can be 'reloaded' if needed.

It makes sense to use TOndemand whenever an object references a 'large' object that is not necessarily available in memory.

E.g. in an image management system an image object could contain textual information, a thumpnail and a 'large' image. For some views it may not be useful to get the 'large' image from the database for every display due to speed reasons. In this case a reference via a TOndemand would be useful.

If objects in one object database should reference objects in another object database, this is only possible with glo::TOndemand.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ TOndemand() [1/7]

template<class T >
glo::TOndemand< T >::TOndemand ( )

Standard constructor.

◆ TOndemand() [2/7]

template<class T >
glo::TOndemand< T >::TOndemand ( const ObjID & rObjID)

Constructor with parameter passing.

Parameters
[in]rObjIDThe object ID of the object to be referenced can be specified during creation.

◆ TOndemand() [3/7]

template<class T >
glo::TOndemand< T >::TOndemand ( Base & rBase)

Constructor with parameter passing.

Parameters
[in]rBaseThe authoritative database can be specified during the creation.

◆ TOndemand() [4/7]

template<class T >
glo::TOndemand< T >::TOndemand ( unsigned long ulDatabaseID)

Constructor with parameter passing.

Parameters
[in]ulDatabaseIDThe authoritative database id can be specified during the creation.

◆ TOndemand() [5/7]

template<class T >
glo::TOndemand< T >::TOndemand ( const ObjID & rObjID,
Base & rBase )

Constructor with parameter passing.

Parameters
[in]rObjIDThe object ID of the object to be referenced and...
[in]rBase...the relevant database can be specified during creation.

◆ TOndemand() [6/7]

template<class T >
glo::TOndemand< T >::TOndemand ( const ObjID & rObjID,
unsigned long ulDatabaseID )

Constructor with parameter passing.

Parameters
[in]rObjIDThe object ID of the object to be referenced and...
[in]ulDatabaseID...the relevant database id can be specified during creation.

◆ TOndemand() [7/7]

template<class T >
glo::TOndemand< T >::TOndemand ( const TOndemand< T > & rT)

Copy constructor.

Parameters
[in]rTThe data is copied from this object.

◆ ~TOndemand()

template<class T >
glo::TOndemand< T >::~TOndemand ( )
virtual

Destructor

Member Function Documentation

◆ get() [1/2]

template<class T >
int glo::TOndemand< T >::get ( std::shared_ptr< T > & rRetVal)

Returns the referenced object from the database (or from memory if already loaded) in a std::shared_ptr.

Parameters
[in,out]rRetValThe referenced object in a std::shared_ptr.
Returns
A return < 0 indicates an error.
If a referenced object does not exist in the database, the error glo::ERR_NO_INDEX is returned.

◆ get() [2/2]

template<class T >
int glo::TOndemand< T >::get ( T *& prObj)

Returns the referenced object from the database (or from memory if already loaded).

Parameters
[in,out]prObjThe pointer reference to the referenced object.
Returns
A return < 0 indicates an error.
If a referenced object does not exist in the database, the error glo::ERR_NO_INDEX is returned.
Attention
The returned object must be removed from memory by the calling instance using BasePersistent::forget().
Note
It is recommended, if possible, to consider using std::shared_ptr and to use the method get(std::shared_ptr<T>&).
Es wird empfohlen, wenn möglich, die Verwendung von std::shared_ptr in Betracht zu ziehen und die Methode get(std::shared_ptr<T>&) zu nutzen.

◆ operator!=()

template<class T >
bool glo::TOndemand< T >::operator!= ( const TOndemand< T > & rT) const

Comparison operator.

Parameters
[in]rTThe object to be compared with this one.

◆ operator=() [1/2]

template<class T >
TOndemand< T > & glo::TOndemand< T >::operator= ( const Reference & rT)

Assignment operator.

Parameters
[in]rTThe data is transferred from this object.

◆ operator=() [2/2]

template<class T >
TOndemand< T > & glo::TOndemand< T >::operator= ( const TOndemand< T > & rT)

Assignment operator.

Parameters
[in]rTThe data is transferred from this object.

◆ operator==()

template<class T >
bool glo::TOndemand< T >::operator== ( const TOndemand< T > & rT) const

Comparison operator.

Parameters
[in]rTThe object to be compared with this one.

◆ set() [1/3]

template<class T >
int glo::TOndemand< T >::set ( const std::shared_ptr< T > & spObj)

Adopts the object ID of the passed object as reference.

Parameters
[in]spObjThe object to be referenced.
Returns
A return value < 0 indicates an error.
Note
Both objects, this one and the one to be referenced must be logged on to the same database.

◆ set() [2/3]

template<class T >
int glo::TOndemand< T >::set ( const T & rObj)

Adopts the object ID of the passed object as reference.

Parameters
[in]rObjThe object to be referenced.
Returns
A return value < 0 indicates an error.
Note
Both objects, this one and the one to be referenced must be logged on to the same database.

◆ set() [3/3]

template<class T >
int glo::TOndemand< T >::set ( const T * pObj)

Adopts the object ID of the passed object as reference.

Parameters
[in]pObjThe pointer to the object to be referenced.
Returns
A return value < 0 indicates an error.
Note
Both objects, this one and the one to be referenced must be logged on to the same database.

◆ setReference()

template<class T >
int glo::TOndemand< T >::setReference ( const ObjID & rObjID)
overridevirtual

Adopts the object ID as reference.

Parameters
[in]rObjIDThe object ID to be referenced.
Note
Both objects, this one and the one to be referenced must be logged on to the same database.

Reimplemented from glo::Reference.


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