CppUnit - The Unit Testing Library

CppUnit project page | FAQ

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{
24public:
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
44protected:
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 private:
64 ExclusiveZone( const ExclusiveZone& );
65
67 ExclusiveZone& operator=( const ExclusiveZone& );
68 };
69
70 virtual void setSynchronizationObject( SynchronizationObject *syncObject );
71
72protected:
73 SynchronizationObject *m_syncObject;
74
75private:
77 SynchronizedObject( const SynchronizedObject &copy );
78
80 void operator =( const SynchronizedObject &copy );
81};
82
83
84 CPPUNIT_NS_END
85
86#endif // CPPUNIT_SYNCHRONIZEDOBJECT_H
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
Portability.h
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:105
SynchronizedObject::ExclusiveZone
Locks a synchronization object in the current scope.
Definition: SynchronizedObject.h:48
SynchronizedObject::ExclusiveZone::ExclusiveZone
ExclusiveZone(const ExclusiveZone &)
Prevents the use of the copy constructor.
SynchronizedObject::ExclusiveZone::~ExclusiveZone
~ExclusiveZone()
Definition: SynchronizedObject.h:58
SynchronizedObject::ExclusiveZone::m_syncObject
SynchronizationObject * m_syncObject
Definition: SynchronizedObject.h:49
SynchronizedObject::ExclusiveZone::operator=
ExclusiveZone & operator=(const ExclusiveZone &)
Prevents the use of the copy operator.
SynchronizedObject::ExclusiveZone::ExclusiveZone
ExclusiveZone(SynchronizationObject *syncObject)
Definition: SynchronizedObject.h:52
SynchronizedObject::SynchronizationObject
Abstract synchronization object (mutex)
Definition: SynchronizedObject.h:28
SynchronizedObject::SynchronizationObject::unlock
virtual void unlock()
Definition: SynchronizedObject.h:34
SynchronizedObject::SynchronizationObject::lock
virtual void lock()
Definition: SynchronizedObject.h:33
SynchronizedObject::SynchronizationObject::SynchronizationObject
SynchronizationObject()
Definition: SynchronizedObject.h:30
SynchronizedObject::SynchronizationObject::~SynchronizationObject
virtual ~SynchronizationObject()
Definition: SynchronizedObject.h:31
SynchronizedObject
Base class for synchronized object.
Definition: SynchronizedObject.h:23
SynchronizedObject::m_syncObject
SynchronizationObject * m_syncObject
Definition: SynchronizedObject.h:73
SynchronizedObject::SynchronizedObject
SynchronizedObject(const SynchronizedObject &copy)
Prevents the use of the copy constructor.

| Send comments to: CppUnit Developers