RWTCountingBody<Mutex> RWTMonitor<Mutex>
#include <rw/pointer/RWTCountingBody.h>
RWTCountingBody<Mutex> is a base class for classes that must maintain a reference count. It can be safely used in a multithreaded environment, when parameterized with a non-null mutex. If multithread safety is not an issue, use a null mutex as the template type.
#include <rw/pointer/RWTCountedPointer.h> #include <rw/pointer/RWTCountingBody.h> #include <rw/sync/RWMutexLock.h> #include <iostream.h> class Foo : public RWTCountingBody<RWMutexLock> {public: void bar(void) { cout << "I'm a foo example" << endl; } }; typedef RWTCountedPointer<Foo> FooPointer; int main(void) { try { FooPointer p1(new Foo); p1->bar(); } catch(RWxmsg& msg) { cout << msg.why() << endl; } return 0; }
RWTCountingBody(RWStaticCtor);
Constructs a static instance (does not initialize the reference count). Throws no exceptions.
RWTCountingBody(const RWTCountingBody<Mutex>& second);
Defines copy constructor, which creates a new instance and initializes the reference count. It doesn't actually copy anything, but allows derived classes to provide a meaningful copy constructor. Throws no exceptions.
RWTCountingBody(unsigned initCount = 0);
Constructs a default instance (initializes the reference count). Throws no exceptions.
RWTCountingBody<Mutex>& operator=(const RWTCountingBody<Mutex>& second);
Defines an assignment operator so derived classes can do assignments. Don't assign the reference count. Throws no exceptions.
unsigned addReference(void);
Increments and returns the reference count.
unsigned references(void) const;
Queries the current reference count. Throws no exceptions.
unsigned removeReference(void);
Decrements and returns the reference count.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.