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

Class to access the persistent objects of a database in memory. More...

#include <GloPersObjectSpy.h>

Public Member Functions

 PersObjectSpy ()
 
virtual ~PersObjectSpy ()
 
PersistentgetPersistentObject (const ObjID &rGloObjID)
 
PersistentgetPersistentObject (EnSeekMode eMode)
 
int getPersistentObject (Persistent *&prRetVal, const ObjID &rGloObjID)
 
int getPersistentObject (Persistent *&prRetVal, EnSeekMode eMode)
 
int getPersistentObject (std::shared_ptr< Persistent > &rRetVal, const ObjID &rGloObjID)
 
int getPersistentObject (std::shared_ptr< Persistent > &rRetVal, EnSeekMode eMode)
 
int insertPersistentObject (const Persistent *pPersObject)
 
int removePersistentObject (const Persistent *pPersObject)
 
std::size_t sizeOfPersObjectList () const
 

Private Member Functions

 PersObjectSpy (const PersObjectSpy &)
 
PersObjectSpyoperator= (const PersObjectSpy &)
 

Private Attributes

eut::CriticalSection m_LocalCriticalSection
 
std::unordered_map< unsigned long, Persistent * > m_PersObjectList
 
std::unordered_map< unsignedlong, Persistent * >::iterator m_PersObjectListIterator
 

Friends

class ObjectMaker
 
class Persistent
 

Detailed Description

Class to access the persistent objects of a database in memory.

All persistent objects of a database log on automatically here.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ PersObjectSpy() [1/2]

glo::PersObjectSpy::PersObjectSpy ( )

Standard constructor.

◆ ~PersObjectSpy()

virtual glo::PersObjectSpy::~PersObjectSpy ( )
virtual

Destructor.

◆ PersObjectSpy() [2/2]

glo::PersObjectSpy::PersObjectSpy ( const PersObjectSpy & )
private

The copy constructor is not available.

Member Function Documentation

◆ getPersistentObject() [1/6]

Persistent * glo::PersObjectSpy::getPersistentObject ( const ObjID & rGloObjID)

Returns a pointer to a persistent object from the list of persistent objects that has the passed object ID.

Parameters
[in]rGloObjIDThe object ID.
Returns
The pointer to the persistent object if found; otherwise NULL_PTR.
Attention
The calling instance must not remove the supplied object from memory.

◆ getPersistentObject() [2/6]

Persistent * glo::PersObjectSpy::getPersistentObject ( EnSeekMode eMode)

Returns a persistent object from the list of persistent objects related to eMode.

Parameters
[in]eModeThe seek mode.

Parameter examples:

Returns
The persistent object if found; otherwise 0.
Attention
The calling instance must not remove the supplied object from memory.

◆ getPersistentObject() [3/6]

int glo::PersObjectSpy::getPersistentObject ( Persistent *& prRetVal,
const ObjID & rGloObjID )

Returns a pointer to a persistent object from the list of persistent objects that has the passed object ID.

Parameters
[in,out]prRetValIf no error, the pointer to the fetched object.
[in]rGloObjIDThe object ID.
Returns
A return value < 0 indicates an error. With a return == ERR_OBJID_NOT_FOUND the object was not found in the m_PersObjectList.
Attention
If prRetVal is valid, this object must be removed from memory by the calling instance using GenericPersistent::forget()
Note
It is recommended, if possible, to consider using std::shared_ptr and to use the method getPersistentObject(std::shared_ptr<Persistent>&, const ObjID&).

◆ getPersistentObject() [4/6]

int glo::PersObjectSpy::getPersistentObject ( Persistent *& prRetVal,
EnSeekMode eMode )

Returns a persistent object from the list of persistent objects related to eMode.

Parameters
[in,out]prRetValIf no error, the pointer to the fetched object.
[in]eModeThe seek mode.

Parameter examples:

Returns
A return < 0 indicates an error. A return == ERR_RANGE indicates the end of the m_PersObjectList
Attention
If prRetVal is valid, this object must be removed from memory by the calling instance using GenericPersistent::forget().
Note
It is recommended, if possible, to consider using std::shared_ptr and to use the method getPersistentObject(std::shared_ptr<Persistent>&, EnSeekMode).

◆ getPersistentObject() [5/6]

int glo::PersObjectSpy::getPersistentObject ( std::shared_ptr< Persistent > & rRetVal,
const ObjID & rGloObjID )

Returns a std::shared_ptr to a persistent object from the list of persistent objects that has the passed object ID.

Parameters
[in,out]rRetValIf no error, the std::shared_ptr to the fetched object.
[in]rGloObjIDThe object ID.
Returns
A return value < 0 indicates an error. With a return == ERR_OBJID_NOT_FOUND the object was not found in the m_PersObjectList.

◆ getPersistentObject() [6/6]

int glo::PersObjectSpy::getPersistentObject ( std::shared_ptr< Persistent > & rRetVal,
EnSeekMode eMode )

Returns a persistent object from the list of persistent objects related to eMode.

Parameters
[in,out]rRetValIf no error, the std::shared_ptr to the fetched object.
[in]eModeThe seek mode.

Parameter examples:

Returns
A return < 0 indicates an error. A return == ERR_RANGE indicates the end of the m_PersObjectList

◆ insertPersistentObject()

int glo::PersObjectSpy::insertPersistentObject ( const Persistent * pPersObject)

Inserts a persistent object into the list of persistent objects.

Parameters
[in]pPersObjectThe persistent object to be inserted.
Returns
A return < 0 indicates an error.

◆ operator=()

PersObjectSpy & glo::PersObjectSpy::operator= ( const PersObjectSpy & )
private

The assignment operator is not available.

◆ removePersistentObject()

int glo::PersObjectSpy::removePersistentObject ( const Persistent * pPersObject)

Removes a persistent object from the list of persistent objects.

Parameters
[in]pPersObjectThe persistent object to be removed.
Returns
A return < 0 indicates an error.

◆ sizeOfPersObjectList()

std::size_t glo::PersObjectSpy::sizeOfPersObjectList ( ) const

Retrurns the number of entries in m_PersObjectList.

Returns
See above.

Friends And Related Symbol Documentation

◆ ObjectMaker

friend class ObjectMaker
friend

◆ Persistent

friend class Persistent
friend

Member Data Documentation

◆ m_LocalCriticalSection

eut::CriticalSection glo::PersObjectSpy::m_LocalCriticalSection
private

To have thread-safe access to the list of persistent objects, access is synchronized via this local CriticalSection.

◆ m_PersObjectList

std::unordered_map< unsigned long, Persistent * > glo::PersObjectSpy::m_PersObjectList
private

The list of generic objects. The index is ObjID::m_ulObjCounter of the object ID of each object.
Since the ObjID::m_ulObjCounter is unique in a database, the entire object ID is not necessary as an index.

◆ m_PersObjectListIterator

std::unordered_map<unsignedlong,Persistent*>::iterator glo::PersObjectSpy::m_PersObjectListIterator
private

An internal iterator to the persistent object list.


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