OSB_LIB::WriteGuard< T * > Class Template Reference

Collaboration diagram for OSB_LIB::WriteGuard< T * >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename T>
class OSB_LIB::WriteGuard< T * >

Write guard a locked pointer.

The template allows to write guard a pointer.

Definition at line 660 of file mutex.h.

Public Member Functions

Copy construction from another pointer type.
The other pointer type S must be convertible to T.

Assignment from another pointer type.
The other pointer type S must be convertible to T.

Non-const construction.
The following constructor and conversion operator are used to achive the non-const copy constructor WriteGuard(WriteGuard) by compiler generated conversions.

Guard related functions:
The following members are wrappers to the RwGuard member of the class, see there for more details.

Public Attributes

Private Attributes

Friends

Classes


Constructor & Destructor Documentation

template<typename T>
OSB_LIB::WriteGuard< T * >::WriteGuard ( T *  ptr = 0,
bool  locked = true,
RwMutex pMutex = 0 
) [inline]

Constructor for the issuer of the guard.

Parameters:
ptr Locked pointer.
locked Flag if the caller of the function owns the appropriate lock when the constructor is called (true is yes, false if no).
pMutex Mutex protecting the pointer.
The constructor initializes it's member RwGuard guard_ to use RwMutex::writeUnlock() when the lock should be released.
The status_ flag is set to 0.

Remarks:
The parameter `locked' should be set to true by the issuer of the guard even if no locking at all is applied. Failing to do so will make it impossible for the receiver of the guard to access the protected pointer with get().

Definition at line 693 of file mutex.h.

template<typename T>
OSB_LIB::WriteGuard< T * >::WriteGuard ( int  stat  )  [inline, explicit]

Constructor to set the status.

Parameters:
stat Status of the guard.
The constructor initializes the member RwGuard guard_ as unlocked and without mutex.

This constructor is typically used by the issuer of the guard when the locking of the mutex failed: see ReadGuard<T*> for a coding example.

Definition at line 712 of file mutex.h.

template<typename T>
OSB_LIB::WriteGuard< T * >::WriteGuard ( WriteGuard< T * > &  rhs  )  [inline]

Non-const copy constructor.

It copies the guard from `rhs', thus transferring the ownership of the lock.

Definition at line 722 of file mutex.h.

template<typename T>
template<typename S>
OSB_LIB::WriteGuard< T * >::WriteGuard ( WriteGuard< S * >  rhs  )  [inline]

Definition at line 753 of file mutex.h.

template<typename T>
OSB_LIB::WriteGuard< T * >::WriteGuard ( WriteGuardRef  r  )  [inline]

Construct from WriteGuardRef, transfers lock ownership.

Definition at line 785 of file mutex.h.


Member Function Documentation

template<typename T>
T* OSB_LIB::WriteGuard< T * >::get (  )  [inline]

Access to the locked pointer.

Returns:
The locked pointer if the guard owns the lock, else 0 (NULL pointer). In the latter case, the caller may check status_ or locked() for the reason.

Definition at line 805 of file mutex.h.

template<typename T>
bool OSB_LIB::WriteGuard< T * >::locked (  )  const [inline]

Lock (still) owned by the guard?

Definition at line 817 of file mutex.h.

template<typename T>
OSB_LIB::WriteGuard< T * >::operator WriteGuardRef (  )  [inline]

Convert to a WriteGuardRef.

Definition at line 795 of file mutex.h.

template<typename T>
template<typename S>
WriteGuard& OSB_LIB::WriteGuard< T * >::operator= ( WriteGuard< S * >  rhs  )  [inline]

Definition at line 767 of file mutex.h.

template<typename T>
WriteGuard& OSB_LIB::WriteGuard< T * >::operator= ( WriteGuard< T * >  rhs  )  [inline]

Non-const assignment operator.

The operator uses memberwise assignment which also includes the guard: A held lock is unlocked and afterwards the ownership of lock is taken from `rhs'.

Definition at line 738 of file mutex.h.

template<typename T>
bool OSB_LIB::WriteGuard< T * >::release (  )  [inline]

Release the lock ownership without unlocking the guard.

Definition at line 823 of file mutex.h.

template<typename T>
void OSB_LIB::WriteGuard< T * >::unlock (  )  [inline]

Unlock the guard.

Definition at line 820 of file mutex.h.


Friends And Related Function Documentation

template<typename T>
friend class WriteGuard [friend]

Provide access to data members for compatible write guards.

Definition at line 663 of file mutex.h.


Member Data Documentation

template<typename T>
RwGuard OSB_LIB::WriteGuard< T * >::guard_ [private]

The actual guard.

Definition at line 842 of file mutex.h.

template<typename T>
T* OSB_LIB::WriteGuard< T * >::ptr_ [private]

Locked pointer.

Definition at line 840 of file mutex.h.

template<typename T>
int OSB_LIB::WriteGuard< T * >::status_

A status flag.

The status flag can be used by the guard's issuer to provide some additional information on the locked resource, e.g., that the latter was deleted.

The interpretation of `status' must be agreed between the issuer and the receiver of the guard.

Definition at line 836 of file mutex.h.


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:11:37 2006 for OSB Library by  doxygen 1.4.7