Home C-Bits Package Documentation Project Page

Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

cbits::TempLock Class Template Reference

Template class for automatically locking/unlocking an embedded object. More...

#include <TempLock.h>

Collaboration diagram for cbits::TempLock:

[legend]
List of all members.

Public Methods

 TempLock (Lockable *l)
 Constructor. More...

 ~TempLock ()
 Destructor. More...

 operator Lockable * ()
 Type conversion operator. More...

 operator Lockable & ()
 Type conversion operator. More...

Lockable & get ()
 Accessor for the embedded object. More...


Private Attributes

Lockable * _lk
 The embedded object. More...


Detailed Description

template<typename Lockable>
class cbits::TempLock< Lockable >

Template class for automatically locking/unlocking an embedded object.

The embedded object's interface must support a lock and unlock method.

For instance:

	class A {
		public:
		void lock();
		void unlock();
		// ...
	};

	// ...

	A a;
	{ // create new scope;
		TempLock<A> locked_a(a);
		// 'a' is now 'locked'
		// ...
	} // end scope
	// 'a' is now unlocked.
 


Constructor & Destructor Documentation

template<typename Lockable>
cbits::TempLock< Lockable >::TempLock Lockable *    l [inline]
 

Constructor.

Locks the embedded object.

Parameters:
l  Object to lock

template<typename Lockable>
cbits::TempLock< Lockable >::~TempLock   [inline]
 

Destructor.

Unlocks the embedded object.


Member Function Documentation

template<typename Lockable>
Lockable& cbits::TempLock< Lockable >::get   [inline]
 

Accessor for the embedded object.

Returns:
reference to the embedded object.

template<typename Lockable>
cbits::TempLock< Lockable >::operator Lockable &   [inline]
 

Type conversion operator.

Allows TempLock instance to be passed in calls that take a reference to the embedded object's type.

template<typename Lockable>
cbits::TempLock< Lockable >::operator Lockable *   [inline]
 

Type conversion operator.

Allows TempLock instance to be passed in calls that take an pointer to embedded object's type.


Member Data Documentation

template<typename Lockable>
Lockable* cbits::TempLock::_lk [private]
 

The embedded object.


The documentation for this class was generated from the following file:
Generated by
doxygen
Hosted by
SourceForge