Ceylan::Lockable Class Reference

Interface which should be implemented for all objects that are able to be locked. More...

#include <CeylanLockable.h>

Inheritance diagram for Ceylan::Lockable:
Inheritance graph
[legend]
Collaboration diagram for Ceylan::Lockable:
Collaboration graph
[legend]

List of all members.

Classes

class  LockException
 This exception is raised when a lock gets misused. More...

Public Types

enum  TextOutputFormat { rawText, html }
 

Defines what text output formats for TextDisplayable instances are available.

More...

Public Member Functions

 Lockable ()
 Basic constructor, Lockable comes unlocked.
virtual ~Lockable () throw ()
 Basic virtual destructor, unlocks Lockable if locked.
virtual bool mustBeLocked () const
bool isLocked () const
 Returns the lock state, locked or unlocked.
virtual void lock ()
 Locks the Lockable.
virtual void unlock ()
 Unlocks the Lockable.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns an user-friendly description of the state of this object.

Static Public Member Functions

static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.

Protected Member Functions

virtual void postLock ()
 Callback method called just after being locked.
virtual void preUnlock ()
 Callback method called just before being unlocked.

Protected Attributes

bool _locked
 This is the actual piece of informations which is used to know the lock state.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.

Private Member Functions

 Lockable (const Lockable &source)
 Copy constructor made private to ensure that it will be never called.
Lockableoperator= (const Lockable &source)
 Assignment operator made private to ensure that it will be never called.

Detailed Description

Interface which should be implemented for all objects that are able to be locked.

Definition at line 48 of file CeylanLockable.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

Lockable::Lockable (  ) 

Basic constructor, Lockable comes unlocked.

Definition at line 62 of file CeylanLockable.cc.

Lockable::~Lockable (  )  throw () [virtual]

Basic virtual destructor, unlocks Lockable if locked.

Definition at line 70 of file CeylanLockable.cc.

References _locked, dataUtils::e, mustBeLocked(), Ceylan::Exception::toString(), and unlock().

Ceylan::Lockable::Lockable ( const Lockable source  )  [private]

Copy constructor made private to ensure that it will be never called.

The compiler should complain whenever this undefined constructor is called, implicitly or not.


Member Function Documentation

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]
bool Ceylan::Lockable::isLocked (  )  const [inline]

Returns the lock state, locked or unlocked.

Note:
Only one of the few inlines for performance reasons.

Definition at line 251 of file CeylanLockable.h.

void Lockable::lock (  )  [virtual]

Locks the Lockable.

Locking an already locked Lockable may raise an exception. If mustBeLocked returns false, does nothing.

This method is to be called by the user of the class instances.

It will handle the locking process and will call the 'postLock' method afterwards. This 'postLock' method should be overriden so that the locking does actually something.

This method, 'lock', may be overriden for special locking processes, for example for reentrant mutex instances.

See also:
isLocked, postLock, unlock

Reimplemented in Ceylan::System::Mutex.

Definition at line 108 of file CeylanLockable.cc.

References _locked, mustBeLocked(), postLock(), and generalUtils::true.

bool Lockable::mustBeLocked (  )  const [virtual]

Definition at line 99 of file CeylanLockable.cc.

References generalUtils::true.

Referenced by lock(), unlock(), and ~Lockable().

Lockable& Ceylan::Lockable::operator= ( const Lockable source  )  [private]

Assignment operator made private to ensure that it will be never called.

The compiler should complain whenever this undefined operator is called, implicitly or not.

void Lockable::postLock (  )  [protected, virtual]

Callback method called just after being locked.

Meant to be overriden if necessary, since this default implementation does nothing.

See also:
lock, preUnlock
Exceptions:
LockException if the effective locking failed.

Reimplemented in Ceylan::System::Mutex.

Definition at line 173 of file CeylanLockable.cc.

Referenced by lock().

void Lockable::preUnlock (  )  [protected, virtual]

Callback method called just before being unlocked.

Meant to be overriden if necessary, since this default implementation does nothing.

See also:
postLock, unlock
Exceptions:
LockException if the effective unlocking failed.

Reimplemented in Ceylan::System::Mutex.

Definition at line 182 of file CeylanLockable.cc.

Referenced by unlock().

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const string Lockable::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable

Implements Ceylan::TextDisplayable.

Reimplemented in Ceylan::System::Mutex.

Definition at line 157 of file CeylanLockable.cc.

References _locked.

void Lockable::unlock (  )  [virtual]

Unlocks the Lockable.

Unlocking a non locked Lockable raises an exception. If mustBeLocked returns false, does nothing.

This method is to be called by the user of the class instances.

It will handle the unlocking process and will call the 'preUnlock' method afterwards. This 'preUnlock' method should be overriden so that the unlocking does actually something.

This method, 'unlock', may be overriden for special unlocking processes, for example for reentrant mutex instances.

See also:
isLocked, preUnlock, lock

Reimplemented in Ceylan::System::Mutex.

Definition at line 133 of file CeylanLockable.cc.

References _locked, generalUtils::false, mustBeLocked(), and preUnlock().

Referenced by ~Lockable().


Member Data Documentation

bool Ceylan::Lockable::_locked [protected]

This is the actual piece of informations which is used to know the lock state.

Definition at line 217 of file CeylanLockable.h.

Referenced by Ceylan::System::Mutex::lock(), lock(), toString(), Ceylan::System::Mutex::unlock(), unlock(), and ~Lockable().

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 13:40:44 2010 for Ceylan by  doxygen 1.6.3