GlobalObjects
Loading...
Searching...
No Matches
glo::Reference Class Reference

The base class of a reference attribute from persistent objects to other persistent objects in the database. More...

#include <GloReference.h>

Inheritance diagram for glo::Reference:

Public Member Functions

 Reference ()
 
 Reference (Base &rBase)
 
 Reference (const ObjID &rObjID)
 
 Reference (const ObjID &rObjID, Base &rBase)
 
 Reference (const ObjID &rObjID, unsigned long ulDatabaseID)
 
 Reference (const Reference &rT)
 
 Reference (unsigned long ulDatabaseID)
 
virtual ~Reference ()
 
virtual int deleteInBase (EnDeepMode eDeepMode=DM_SHALLOW)
 
virtual BasegetBase () const override
 
ObjID getObjID () const
 
const ObjIDgetObjIDAsPointer () const
 
int getReference (BasePersistent *&prRetVal)
 
int getReference (std::shared_ptr< BasePersistent > &sprRetVal)
 
virtual int getTypeAsString (std::string &rsTypeName) override
 
virtual int isLocked (const LockSpecification &rLockSpecification) const
 
virtual int isLocked (EnLockMode eLockMode=LK_DELETEvWRITE, EnDeepMode eDeepMode=DM_SHALLOW) const
 
bool isNULL () 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 lock (const LockSpecification &rLockSpecification) const
 
virtual int lock (EnLockMode eLockMode=LK_DELETEvWRITE, EnDeepMode eDeepMode=DM_SHALLOW) const
 
Referenceoperator= (const Reference &rT)
 
virtual int setBase (Base *pBase) override
 
void setNULL ()
 
int setReference (const BasePersistent &rObj)
 
int setReference (const BasePersistent *pObj)
 
virtual int setReference (const ObjID &rObjID)
 
virtual int setWatch (const WatchSpecification &rWatchSpec) const
 
virtual int setWatch (TdWatchNotifyMode ulWatchMode, EnDeepMode eDeepMode, CallBack *pCallBack=0) const
 
virtual int unlock (const LockSpecification &rLockSpecification) const
 
virtual int unlock (EnLockMode eLockMode=LK_DELETEvWRITE, EnDeepMode eDeepMode=DM_SHALLOW) const
 
virtual int unsetWatch (const WatchSpecification &rWatchSpec) const
 
virtual int unsetWatch (TdWatchNotifyMode ulWatchMode, EnDeepMode eDeepMode, CallBack *pCallBack) const
 
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.
 

Private Attributes

ObjID m_RefObjID
 
unsigned long m_ulDatabaseID
 

Friends

class Base
 
class BaseAllSet
 
class ObjectMaker
 
class OdRefRecordAttribute
 
class OndemandList
 
class OndemandLot
 
class OndemandSet
 
class TableReaderInterface
 

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 deinit ()
 
void init ()
 

Detailed Description

The base class of a reference attribute from persistent objects to other persistent objects in the database.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ Reference() [1/7]

glo::Reference::Reference ( )

Standard constructor.

◆ Reference() [2/7]

glo::Reference::Reference ( const ObjID & rObjID)

Constructor with parameter passing.

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

◆ Reference() [3/7]

glo::Reference::Reference ( Base & rBase)

Constructor with parameter passing.

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

◆ Reference() [4/7]

glo::Reference::Reference ( unsigned long ulDatabaseID)

Constructor with parameter passing.

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

◆ Reference() [5/7]

glo::Reference::Reference ( 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.
Exceptions
eut::ErrorNExceptionIf the database IDs of the passed object ID and the database do not match, an exception is thrown.

◆ Reference() [6/7]

glo::Reference::Reference ( 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.
Exceptions
eut::ErrorNExceptionIf the database IDs of the passed object ID and the database do not match, an exception is thrown.

◆ Reference() [7/7]

glo::Reference::Reference ( const Reference & rT)

Copy constructor.

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

◆ ~Reference()

virtual glo::Reference::~Reference ( )
virtual

Destructor.

Member Function Documentation

◆ deleteInBase()

virtual int glo::Reference::deleteInBase ( EnDeepMode eDeepMode = DM_SHALLOW)
virtual

Referenced object is deleted from the database.

Parameters
[in]eDeepModeThe Deep Mode
Returns
A return < 0 indicates an error.

◆ getBase()

virtual Base * glo::Reference::getBase ( ) const
overridevirtual
Returns
Returns pointers to the database.
Attention
The object returned must not be removed from memory by the calling instance.
See also
setBase(Base*)

Reimplemented from glo::CallBack.

◆ getObjID()

ObjID glo::Reference::getObjID ( ) const

Returns the object ID of the reference.

Returns
See above.

◆ getObjIDAsPointer()

const ObjID * glo::Reference::getObjIDAsPointer ( ) const

Returns the object ID of the reference as pointer.

Returns
See above.

◆ getReference() [1/2]

int glo::Reference::getReference ( BasePersistent *& prRetVal)

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

Parameters
[in,out]prRetValThe referenced object.
Returns
A return value < 0 indicates an error.
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 getReference(std::shared_ptr<BasePersistent>&).

◆ getReference() [2/2]

int glo::Reference::getReference ( std::shared_ptr< BasePersistent > & sprRetVal)

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

Parameters
[in,out]sprRetValThe referenced object.
Returns
A return value < 0 indicates an error.

◆ getTypeAsString()

virtual int glo::Reference::getTypeAsString ( std::string & rsTypeName)
overridevirtual

Returns the type of the reference, i.e. the class name as string when connected to the database.

Parameters
[in,out]rsTypeNameThe type name.
Returns
If return value < 0, then an error has occurred.

Reimplemented from glo::CallBack.

◆ isLocked() [1/2]

virtual int glo::Reference::isLocked ( const LockSpecification & rLockSpecification) const
virtual

Checks if referenced object is locked in the database with the passed parameters.

Parameters
[in]rLockSpecificationThe lock and lock depth mode.
Returns
If > 0, the object is locked in the database. A return value < 0 indicates an error.
See also
Check object for locks or access possibilities.

◆ isLocked() [2/2]

virtual int glo::Reference::isLocked ( EnLockMode eLockMode = LK_DELETEvWRITE,
EnDeepMode eDeepMode = DM_SHALLOW ) const
virtual

Checks if referenced object is locked in the database with the passed parameters.

Parameters
[in]eLockModeThe lock mode.
[in]eDeepModeThe lock depth mode.
Returns
If > 0, the object is locked in the database. A return value < 0 indicates an error.
See also
Check object for locks or access possibilities.

◆ isNULL()

bool glo::Reference::isNULL ( ) const

Checks if the reference is formally valid.

Returns
Returns true if the reference is formally invalid.

◆ isPossible() [1/2]

virtual int glo::Reference::isPossible ( bool bRead,
bool bWrite,
bool bDelete,
EnDeepMode eDeepMode = DM_SHALLOW ) const
virtual

Checks the allowed actions for the referenced object in the database.

Parameters
[in]bReadIf true, the read permission is checked.
[in]bWriteIf true, the write permission is checked.
[in]bDeleteIf true, a check is made for delete permissions.
[in]eDeepModeThe depth mode for which it is checked.
Returns
. If return == 0, the respective action is allowed. A return < 0 indicates an error.
See also
Check object for locks or access possibilities.

◆ isPossible() [2/2]

virtual int glo::Reference::isPossible ( const LockPossibleSpecification & rLockPossibleSpec,
EnDeepMode eDeepMode = DM_SHALLOW ) const
virtual

Checks the allowed actions for the referenced object in the database.

Parameters
[in]rLockPossibleSpecThe possibility request.
[in]eDeepModeThe depth mode for which it is checked.
Returns
. If return == 0, the respective action is allowed. A return < 0 indicates an error.
See also
Check object for locks or access possibilities.

◆ lock() [1/2]

virtual int glo::Reference::lock ( const LockSpecification & rLockSpecification) const
virtual

The referenced object is locked in the database for other clients.

Parameters
[in]rLockSpecificationThe lock- and lock depth mode.
Returns
A return value < 0 indicates an error.
Note
To unlock the lock, the corresponding method unlock(const LockSpecification&) const with the same parameter value must be used.
See also
Locking a persistent object.

◆ lock() [2/2]

virtual int glo::Reference::lock ( EnLockMode eLockMode = LK_DELETEvWRITE,
EnDeepMode eDeepMode = DM_SHALLOW ) const
virtual

The referenced object is locked in the database for other clients.

Parameters
[in]eLockModeThe lock mode.
[in]eDeepModeThe lock depth mode.
Returns
A return value < 0 indicates an error.
Note
To unlock the lock, the corresponding method unlock(EnLockMode, EnDeepMode) const with the same parameter values must be used.
See also
Locking a persistent object.

◆ operator!=()

bool glo::Reference::operator!= ( const Reference & rT) const

Comparison operator.

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

◆ operator=()

Reference & glo::Reference::operator= ( const Reference & rT)

Assignment operator.

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

◆ operator==()

bool glo::Reference::operator== ( const Reference & rT) const

Comparison operator.

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

◆ setBase()

virtual int glo::Reference::setBase ( Base * pBase)
overridevirtual

Sets the pointer to the database.

Parameters
[in]pBasePointer to the database.
Returns
If return value < 0, then an error has occurred.
Attention
The database remains the responsibility of the calling instance. If, for example, the database is removed from memory, setBase(Base*) must first be called with nullptr or removeBase().

Reimplemented from glo::CallBack.

◆ setNULL()

void glo::Reference::setNULL ( )

Sets the reference to formally invalid.

◆ setReference() [1/3]

int glo::Reference::setReference ( const BasePersistent & rObj)

Adopts the object ID of the passed object as reference. Both objects, this and the object to be referenced must be logged on to the same database.

Parameters
[in]rObjThe object ID of the object to be referenced.
Returns
A return value < 0 indicates an error.

◆ setReference() [2/3]

int glo::Reference::setReference ( const BasePersistent * pObj)

Adopts the object ID of the passed object as reference. Both objects, this and the object to be referenced must be logged on to the same database.

Parameters
[in]pObjThe object ID of the object to be referenced.
Returns
A return value < 0 indicates an error.

◆ setReference() [3/3]

virtual int glo::Reference::setReference ( const ObjID & rObjID)
virtual

Adopts the object ID.

Parameters
[in]rObjIDThe object ID of the object to be referenced.
Returns
A return value < 0 indicates an error.

Reimplemented in glo::TOndemand< T >.

◆ setWatch() [1/2]

virtual int glo::Reference::setWatch ( const WatchSpecification & rWatchSpec) const
virtual

The referenced object is monitored in the database.

Parameters
[in]rWatchSpecThe monitoring specification.
Returns
A return < 0 indicates an error.
Note
To cancel the monitoring, the corresponding method unsetWatch(const WatchSpecification&) const must be used with the same parameter values.
See also
Watch and notify.

◆ setWatch() [2/2]

virtual int glo::Reference::setWatch ( TdWatchNotifyMode ulWatchMode,
EnDeepMode eDeepMode,
CallBack * pCallBack = 0 ) const
virtual

The referenced object is monitored in the database.

Parameters
[in]ulWatchModeThe watch mode.
Allowed watch modes:
[in]eDeepModeThe watching depth mode.
[in]pCallBackThe CallBack object that is notified via its method CallBack::notify(NotifyNote&). If no CallBack is passed, notify(NotifyNote&) is taken from this; in this case the method notify(NotifyNote&) should be overwritten in the respective derived class.
Returns
A return value < 0 indicates an error.
Note
To remove the monitoring, the corresponding method unsetWatchObject(TdWatchNotifyMode, EnDeepMode, CallBack*) const with same parameter values can be used.
Attention
Basically pCallBack must not be destroyed before the monitoring has been cancelled!
See also
Watch and notify.

◆ unlock() [1/2]

virtual int glo::Reference::unlock ( const LockSpecification & rLockSpecification) const
virtual

The referenced object is released in the database. A lock release must be called with the same parameters as the previous lock call.

Parameters
[in]rLockSpecificationThe original lock and lock depth mode.
Returns
A return value < 0 indicates an error.
Note
Removes the lock initiated by the corresponding method lock(const LockSpecification&) const if the parameter has the same values.
See also
Locking a persistent object.

◆ unlock() [2/2]

virtual int glo::Reference::unlock ( EnLockMode eLockMode = LK_DELETEvWRITE,
EnDeepMode eDeepMode = DM_SHALLOW ) const
virtual

The referenced object is released in the database. A lock release must be called with the same parameters as the previous lock call.

Parameters
[in]eLockModeThe original lock mode.
[in]eDeepModeThe original lock depth mode.
Returns
A return < 0 indicates an error.
Note
Removes the lock initiated by the corresponding method lock(EnLockMode, EnDeepMode) const if the parameters have the same values.
See also
Locking a persistent object.

◆ unsetWatch() [1/2]

virtual int glo::Reference::unsetWatch ( const WatchSpecification & rWatchSpec) const
virtual

The monitoring of the referenced object in the database is terminated. A monitoring termination must be called with the same parameters as the previous monitoring.

Parameters
[in]rWatchSpecThe original monitoring specification.
Returns
A return < 0 indicates an error.
Note
Clears the monitoring initiated by the corresponding method setWatch(const WatchSpecification&) const if the parameters have the same values.
See also
Watch and notify.

◆ unsetWatch() [2/2]

virtual int glo::Reference::unsetWatch ( TdWatchNotifyMode ulWatchMode,
EnDeepMode eDeepMode,
CallBack * pCallBack ) const
virtual

The monitoring of the referenced object in the database is terminated. A monitoring termination must be called with the same parameters as the previous monitoring.

Parameters
[in]ulWatchModeThe original watch mode.
Allowed watch modes:
[in]eDeepModeThe original monitoring depth mode.
[in]pCallBackThe CallBack object that is notified via its method CallBack::notify(NotifyNote&). If no CallBack is passed, notify(NotifyNote&) is taken from this; in this case the method notify(NotifyNote&) should be overwritten in the respective derived class.
Returns
A return value < 0 indicates an error.
Note
Clears the monitoring initiated by the corresponding method setWatchObject(TdWatchNotifyMode, EnDeepMode, CallBack*) const if the parameters have the same values.
See also
Watch and notify.

Friends And Related Symbol Documentation

◆ Base

friend class Base
friend

◆ BaseAllSet

friend class BaseAllSet
friend

◆ ObjectMaker

friend class ObjectMaker
friend

◆ OdRefRecordAttribute

friend class OdRefRecordAttribute
friend

◆ OndemandList

friend class OndemandList
friend

◆ OndemandLot

friend class OndemandLot
friend

◆ OndemandSet

friend class OndemandSet
friend

◆ TableReaderInterface

friend class TableReaderInterface
friend

Member Data Documentation

◆ m_RefObjID

ObjID glo::Reference::m_RefObjID
private

The reference to a persistent object as object ID.

◆ m_ulDatabaseID

unsigned long glo::Reference::m_ulDatabaseID
private

The reference to a database via the database ID.


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