SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Base class for classes that must maintain a reference count. More...
#include <rw/pointer/RWTCountingBody.h>
Public Member Functions | |
~RWTCountingBody (void) | |
unsigned | references (void) const |
unsigned | addReference (void) |
unsigned | removeReference (void) |
Protected Types | |
typedef RWTLockGuard < RWTMonitor< Mutex > > | LockGuard |
typedef RWTUnlockGuard < RWTMonitor< Mutex > > | UnlockGuard |
typedef RWTTryLockGuard < RWTMonitor< Mutex > > | TryLockGuard |
Protected Member Functions | |
RWTCountingBody (unsigned initCount=0) | |
RWTCountingBody (RWStaticCtor) | |
RWTCountingBody (const RWTCountingBody< Mutex > &second) | |
RWTCountingBody< Mutex > & | operator= (const RWTCountingBody< Mutex > &second) |
RWTCountingBody<Mutex> is a base class for classes that must maintain a reference count. It can be safely used in a multithreaded environment.
#include <rw/pointer/RWTCountedPointer.h> #include <rw/pointer/RWTCountingBody.h> #include <rw/sync/RWMutexLock.h> #include <iostream> class Foo : public RWTCountingBody<RWMutexLock> { public: void bar(void) { std::cout << "I'm a foo example" << std::endl; } }; typedef RWTCountedPointer<Foo> FooPointer; int main(void) { try { FooPointer p1(new Foo); p1->bar(); } catch(const RWxmsg& msg) { std::cout << msg.why() << std::endl; } return 0; }
typedef RWTLockGuard< RWTMonitor<Mutex> > RWTCountingBody< Mutex >::LockGuard [protected] |
Predefined type for compatible guard.
Reimplemented from RWTMonitor< Mutex >.
typedef RWTTryLockGuard< RWTMonitor<Mutex> > RWTCountingBody< Mutex >::TryLockGuard [protected] |
Predefined type for compatible guard.
Reimplemented from RWTMonitor< Mutex >.
typedef RWTUnlockGuard< RWTMonitor<Mutex> > RWTCountingBody< Mutex >::UnlockGuard [protected] |
Predefined type for compatible guard.
Reimplemented from RWTMonitor< Mutex >.
RWTCountingBody< Mutex >::~RWTCountingBody | ( | void | ) | [inline] |
Destructor.
RWTCountingBody< Mutex >::RWTCountingBody | ( | unsigned | initCount = 0 |
) | [inline, protected] |
Constructs a default instance (initializes the reference count). Throws no exceptions.
RWTCountingBody< Mutex >::RWTCountingBody | ( | RWStaticCtor | ) | [inline, protected] |
Constructs a static instance (does not initialize the reference count). Throws no exceptions.
RWTCountingBody< Mutex >::RWTCountingBody | ( | const RWTCountingBody< Mutex > & | second | ) | [inline, protected] |
Defines a copy constructor that creates a new instance and initializes the reference count. This constructor does not actually create a copy, but allows derived classes to provide a meaningful copy constructor. Throws no exceptions.
unsigned RWTCountingBody< Mutex >::addReference | ( | void | ) |
Increments the reference count and then returns the previous value minus one.
Reimplemented in RWBodyBase.
RWTCountingBody< Mutex > & RWTCountingBody< Mutex >::operator= | ( | const RWTCountingBody< Mutex > & | second | ) | [inline, protected] |
Defines an assignment operator, allowing derived classes to do assignments. Don't assign the reference count. Throws no exceptions.
unsigned RWTCountingBody< Mutex >::references | ( | void | ) | const |
Queries the current reference count. Throws no exceptions.
Reimplemented in RWBodyBase.
unsigned RWTCountingBody< Mutex >::removeReference | ( | void | ) |
Decrements the reference count and then returns the previous value minus one.
Reimplemented in RWBodyBase.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.