00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_LOCKABLE_H_
00028 #define CEYLAN_LOCKABLE_H_
00029
00030
00031 #include "CeylanException.h"
00032 #include "CeylanTextDisplayable.h"
00033
00034
00035
00036 #include <string>
00037
00038
00039 namespace Ceylan
00040 {
00041
00042
00048 class CEYLAN_DLL Lockable : public Ceylan::TextDisplayable
00049 {
00050
00051
00052
00053 public:
00054
00055
00056
00058 class CEYLAN_DLL LockException : public Ceylan::Exception
00059 {
00060
00061 public :
00062
00063 explicit LockException( const std::string & reason ) ;
00064
00065 virtual ~LockException() throw() ;
00066
00067 } ;
00068
00069
00070
00071
00073 Lockable() ;
00074
00075
00076
00078 virtual ~Lockable() throw() ;
00079
00080
00081
00096 virtual bool mustBeLocked() const ;
00097
00098
00099
00107 inline bool isLocked() const ;
00108
00109
00110
00131 virtual void lock() ;
00132
00133
00134
00156 virtual void unlock() ;
00157
00158
00159
00172 virtual const std::string toString(
00173 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00174
00175
00176
00177
00178 protected:
00179
00180
00181
00193 virtual void postLock() ;
00194
00195
00196
00208 virtual void preUnlock() ;
00209
00210
00211
00217 bool _locked ;
00218
00219
00220
00221
00222 private:
00223
00224
00233 Lockable( const Lockable & source ) ;
00234
00235
00244 Lockable & operator = ( const Lockable & source ) ;
00245
00246
00247 } ;
00248
00249
00250
00251 bool Lockable::isLocked() const
00252 {
00253
00254 return _locked ;
00255
00256 }
00257
00258
00259 }
00260
00261
00262
00263 #endif // CEYLAN_LOCKABLE_H_
00264