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

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

#include <GloGenPersObjectSpy.h>

Public Member Functions

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

Private Member Functions

 GenPersObjectSpy (const GenPersObjectSpy &)
 
GenPersObjectSpyoperator= (const GenPersObjectSpy &)
 

Private Attributes

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

Friends

class GenericPersistent
 

Detailed Description

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

All generic persistent objects of a database log on automatically here.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ GenPersObjectSpy() [1/2]

glo::GenPersObjectSpy::GenPersObjectSpy ( )

Standard constructor.

◆ ~GenPersObjectSpy()

virtual glo::GenPersObjectSpy::~GenPersObjectSpy ( )
virtual

Destructor.

◆ GenPersObjectSpy() [2/2]

glo::GenPersObjectSpy::GenPersObjectSpy ( const GenPersObjectSpy & )
private

The copy constructor is not available.

Member Function Documentation

◆ getPersistentObject() [1/6]

GenericPersistent * glo::GenPersObjectSpy::getPersistentObject ( const ObjID & rGloObjID)

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

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

◆ getPersistentObject() [2/6]

GenericPersistent * glo::GenPersObjectSpy::getPersistentObject ( EnSeekMode eMode)

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

Parameters
[in]eModeThe seek mode.

Parameter examples:

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

◆ getPersistentObject() [3/6]

int glo::GenPersObjectSpy::getPersistentObject ( GenericPersistent *& prRetVal,
const ObjID & rGloObjID )

Returns a pointer to a generic persistent object from the list of generic 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<GenericPersistent>&, const ObjID&).

◆ getPersistentObject() [4/6]

int glo::GenPersObjectSpy::getPersistentObject ( GenericPersistent *& prRetVal,
EnSeekMode eMode )

Returns a generic persistent object from the list of generic 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<GenericPersistent>&, EnSeekMode).

◆ getPersistentObject() [5/6]

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

Returns a std::shared_ptr to a generic persistent object from the list of generic 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::GenPersObjectSpy::getPersistentObject ( std::shared_ptr< GenericPersistent > & rRetVal,
EnSeekMode eMode )

Returns a generic persistent object from the list of generic 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::GenPersObjectSpy::insertPersistentObject ( const GenericPersistent * pPersObject)

Inserts a generic persistent object into the list of generic persistent objects.

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

◆ operator=()

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

The assignment operator is not available.

◆ removePersistentObject()

int glo::GenPersObjectSpy::removePersistentObject ( const GenericPersistent * pPersObject)

Removes a generic persistent object from the list of generic persistent objects.

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

◆ sizeOfPersObjectList()

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

Retrurns the number of entries in m_PersObjectList.

Returns
See above.

Friends And Related Symbol Documentation

◆ GenericPersistent

friend class GenericPersistent
friend

Member Data Documentation

◆ m_LocalCriticalSection

eut::CriticalSection glo::GenPersObjectSpy::m_LocalCriticalSection
private

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

◆ m_PersObjectList

std::unordered_map< unsigned long, GenericPersistent * > glo::GenPersObjectSpy::m_PersObjectList
private

The list of generic persistent 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,GenericPersistent*>::iterator glo::GenPersObjectSpy::m_PersObjectListIterator
private

An internal iterator to the generic persistent object list.


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