CppUnit project page | FAQ

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

SynchronizedObject.h
Go to the documentation of this file.
1 #ifndef CPPUNIT_SYNCHRONIZEDOBJECT_H
2 #define CPPUNIT_SYNCHRONIZEDOBJECT_H
3
4 #include <cppunit/Portability.h>
5
6
7 CPPUNIT_NS_BEGIN
8
9
22 class CPPUNIT_API SynchronizedObject
23 {
24 public:
27 class SynchronizationObject
28 {
29 public:
30 SynchronizationObject() {}
31 virtual ~SynchronizationObject() {}
32
33 virtual void lock() {}
34 virtual void unlock() {}
35 };
36
39 SynchronizedObject( SynchronizationObject *syncObject =0 );
40
42 virtual ~SynchronizedObject();
43
44 protected:
47 class ExclusiveZone
48 {
49 SynchronizationObject *m_syncObject;
50
51 public:
52 ExclusiveZone( SynchronizationObject *syncObject )
53 : m_syncObject( syncObject )
54 {
55 m_syncObject->lock();
56 }
57
58 ~ExclusiveZone()
59 {
60 m_syncObject->unlock ();
61 }
62 };
63
64 virtual void setSynchronizationObject( SynchronizationObject *syncObject );
65
66 protected:
67 SynchronizationObject *m_syncObject;
68
69 private:
71 SynchronizedObject( const SynchronizedObject &copy );
72
74 void operator =( const SynchronizedObject &copy );
75 };
76
77
78 CPPUNIT_NS_END
79
80 #endif // CPPUNIT_SYNCHRONIZEDOBJECT_H
SynchronizedObject::ExclusiveZone
Locks a synchronization object in the current scope.
Definition: SynchronizedObject.h:47
Portability.h
SynchronizedObject::m_syncObject
SynchronizationObject * m_syncObject
Definition: SynchronizedObject.h:67
SynchronizedObject::ExclusiveZone::ExclusiveZone
ExclusiveZone(SynchronizationObject *syncObject)
Definition: SynchronizedObject.h:52
SynchronizedObject::SynchronizationObject::unlock
virtual void unlock()
Definition: SynchronizedObject.h:34
SynchronizedObject::SynchronizationObject
Abstract synchronization object (mutex)
Definition: SynchronizedObject.h:27
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:120
SynchronizedObject::SynchronizationObject::SynchronizationObject
SynchronizationObject()
Definition: SynchronizedObject.h:30
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:119
SynchronizedObject::SynchronizationObject::~SynchronizationObject
virtual ~SynchronizationObject()
Definition: SynchronizedObject.h:31
SynchronizedObject::SynchronizationObject::lock
virtual void lock()
Definition: SynchronizedObject.h:33
SynchronizedObject::ExclusiveZone::~ExclusiveZone
~ExclusiveZone()
Definition: SynchronizedObject.h:58
SynchronizedObject::ExclusiveZone::m_syncObject
SynchronizationObject * m_syncObject
Definition: SynchronizedObject.h:49
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
SynchronizedObject
Base class for synchronized object.
Definition: SynchronizedObject.h:22

| Send comments to: CppUnit Developers