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

Objects of this class monitor the lock state of persistent objects. More...

#include <GloLockManager.h>

Classes

class  LockedObject
 Objects can be locked. Objects of this class represent an object locked by the communicator, with possibly also locked objects like embedded objects. More...
 

Public Member Functions

 LockManager (Manager *pDBManager)
 
virtual ~LockManager ()
 
void deleteAllLocks (Communicator *pCommunicator, const std::string &rsSchemaName)
 
void getNotAllowedReadObjects (std::list< ObjID > &rReadLockObjList, Communicator *pCommunicator) const
 
LockPossibleSpecification getProcessingPossibilities (const ObjID &rObjID, std::map< ObjID, Record *, std::less< ObjID > > &rDependObjects, Communicator *pCommunicator)
 
bool isPossible (const ObjID &rObjID, std::map< ObjID, Record *, std::less< ObjID > > &rDependObjects, Communicator *pCommunicator, bool bRead, bool bWrite, bool bDelete)
 
int lockObject (const ObjID &rObjID, std::map< ObjID, Record *, std::less< ObjID > > &rDependObjects, Communicator *pCommunicator, const std::string &rsSchemaName, EnLockMode eLockMode, EnDeepMode eDeepMode, bool bSimulate=false)
 
int unlockObject (const ObjID &rObjID, Communicator *pCommunicator, const std::string &rsSchemaName, EnLockMode eLockMode, EnDeepMode eDeepMode, bool bSimulate=false)
 

Protected Member Functions

 LockManager ()
 

Private Member Functions

 LockManager (const LockManager &)
 
LockManageroperator= (const LockManager &)
 
void sendNotify (TdWatchNotifyMode nWatchNotifyMode, const ObjID &rObjID, Communicator *pCommunicator, const std::string &rsSchemaName)
 

Private Attributes

std::unordered_map< unsigned long, LockedObject * > m_LockedObjectMap
 
Managerm_pDBManager
 

Detailed Description

Objects of this class monitor the lock state of persistent objects.

No lock states are stored in the tables. The Manager must register objects for locking (with the locking or releasing communicator) and always ask before actions whether they are allowed. Lock states of single objects can be requested.

Since an object should be able to be locked e.g. with its dependent objects, objects are passed with their dependent objects to lock. The lock possibility of each object is checked and if possible all objects are locked with passed lock mode or none.

For each lock mode there is a list in which the list of dependent objects with the lock depth mode is stored.

When an object is released with a specific lock mode and lock depth mode, the list is removed from the lock mode list and any objects contained are also released with the same lock mode.

This is necessary because, for example, an object 'A' can be locked with a referenced object 'B'. The application can now dereference the referenced object 'B' into object 'A'. When object 'A' is released, the previously referenced object 'B' is no longer linked to object 'A' and would therefore not be released.

The following table lists the individual lock modes and their effects.

The following abbreviations apply to the lock modes:

The following abbreviations apply to actions:

  • R -> Read
  • W -> Write
  • D -> Delete
Blocking modes and their effects
Locking instanceOther instances
Lock modeGuarantee to do...Protect from...Allowed lock modesPossibilitiesRestrictions
NNnonenoneallallnone
RDRDRD, RW, WW, TWR, WD
RWRD, WRD, RWRD, W
WWR, WD, WRDRD, W
DWR, W, DD, WnoneRD, W
DRR, W, DD, W, RnonenoneD, R, W
EXR, W, DD, W, RnonenoneD, R, W
TWR, WD, WRDRD, W
TDR, W, DD, WnoneRD, W



The structure of the LockManager looks like this:

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ LockManager() [1/3]

glo::LockManager::LockManager ( )
protected

The default constructor is not available.

◆ LockManager() [2/3]

glo::LockManager::LockManager ( Manager * pDBManager)

Constructor with parameter passing.

Parameters
[in]pDBManagerBackreference to the owning Manager, must not be removed from memory during the lifetime of this object.

◆ ~LockManager()

virtual glo::LockManager::~LockManager ( )
virtual

Destructor, cleaning up.

◆ LockManager() [3/3]

glo::LockManager::LockManager ( const LockManager & )
private

The copy constructor is not available.

Member Function Documentation

◆ deleteAllLocks()

void glo::LockManager::deleteAllLocks ( Communicator * pCommunicator,
const std::string & rsSchemaName )

All locks of the passed communicator are removed.

Parameters
[in]pCommunicatorThe communicator.
[in]rsSchemaNameThe schema name is used for notification.

◆ getNotAllowedReadObjects()

void glo::LockManager::getNotAllowedReadObjects ( std::list< ObjID > & rReadLockObjList,
Communicator * pCommunicator ) const

Returns all object IDs of the read-only objects for the passed communicator.

Parameters
[in,out]rReadLockObjListThe object IDs of the read locked objects.
[in]pCommunicatorThe communicator.

◆ getProcessingPossibilities()

LockPossibleSpecification glo::LockManager::getProcessingPossibilities ( const ObjID & rObjID,
std::map< ObjID, Record *, std::less< ObjID > > & rDependObjects,
Communicator * pCommunicator )

Returns the possible action with an object for a communicator.

Parameters
[in]rObjIDThe object ID to be checked.
[in]rDependObjectsThe map of data sets of the objects to be checked.
[in]pCommunicatorThe communicator.
Returns
The possibilities in a LockPossibleSpecification.

◆ isPossible()

bool glo::LockManager::isPossible ( const ObjID & rObjID,
std::map< ObjID, Record *, std::less< ObjID > > & rDependObjects,
Communicator * pCommunicator,
bool bRead,
bool bWrite,
bool bDelete )

Checks whether the transferred communicator is allowed to read, write and/or delete the object with transferred object ID.

Parameters
[in]rObjIDThe object ID to be checked.
[in]rDependObjectsThe map of data sets of the objects to be checked.
[in]pCommunicatorThe communicator.
[in]bReadIf true, a 'read' check is performed.
[in]bWriteIf true, a 'write' check is performed.
[in]bDeleteIf true, checks for 'delete'.
Returns
If true, the true set modes are possible for the communicator.

◆ lockObject()

int glo::LockManager::lockObject ( const ObjID & rObjID,
std::map< ObjID, Record *, std::less< ObjID > > & rDependObjects,
Communicator * pCommunicator,
const std::string & rsSchemaName,
EnLockMode eLockMode,
EnDeepMode eDeepMode,
bool bSimulate = false )

Locks an object with passed object ID for a communicator.

Parameters
[in]rObjIDThe object ID of the object to be locked.
[in]rDependObjectsThe map of records of the objects to be locked.
[in]pCommunicatorThe locking communicator.
[in]rsSchemaNameThe schema name is used for notification.
[in]eLockModeThe locking mode.
[in]eDeepModeThe lock depth mode.
[in]bSimulateIf true, only simulation is used, no value is set, but a valid result or error is returned.
Returns
A return value < 0 indicates an error.

◆ operator=()

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

The assignment operator is not available.

◆ sendNotify()

void glo::LockManager::sendNotify ( TdWatchNotifyMode nWatchNotifyMode,
const ObjID & rObjID,
Communicator * pCommunicator,
const std::string & rsSchemaName )
private

Initiates a Notify via its m_pDBManager.

Parameters
[in]nWatchNotifyModeThe watch mode.
[in]rObjIDThe Object-ID of the affected object.
[in]pCommunicatorThe communicator.
[in]rsSchemaNameThe schema name is used for notification.

◆ unlockObject()

int glo::LockManager::unlockObject ( const ObjID & rObjID,
Communicator * pCommunicator,
const std::string & rsSchemaName,
EnLockMode eLockMode,
EnDeepMode eDeepMode,
bool bSimulate = false )

Releases the object locked by a communicator with passed object ID.

Parameters
[in]rObjIDThe object ID of the object to be released.
[in]pCommunicatorThe releasing communicator.
[in]rsSchemaNameThe schema name is used for notification.
[in]eLockModeThe locking mode.
[in]eDeepModeThe lock depth mode.
[in]bSimulateIf true, only simulation is used, no value is set, but a valid result or error is returned.
Returns
A return value < 0 indicates an error.

Member Data Documentation

◆ m_LockedObjectMap

std::unordered_map< unsigned long, LockedObject * > glo::LockManager::m_LockedObjectMap
private

List of the locked objects.

◆ m_pDBManager

Manager* glo::LockManager::m_pDBManager
private

Back reference to the owning Manager.


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