bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
|
A base class for a simple reference counted object. More...
#include <RCObject.h>
Public Member Functions | |
void | addPreDeleteCB (UseCountHitZeroCB *pCB) |
virtual int | getRefCount () const |
RCObject (const RCObject &proto) | |
RCObject (RCObjectPool *pool=0) | |
virtual int | ref () const |
virtual void | removeFromPool () const |
void | removePreDeleteCB (UseCountHitZeroCB *pCB) |
virtual std::string | toString () const |
virtual int | unref () const |
Friends | |
class | RCObjectPool |
A base class for a simple reference counted object.
Use as a base class for objects that need to delete themselves when their reference count goes to 0.
When a strong reference to the object is required, the caller uses ref(). When the reference needs to be released, unref() is called. p->unref() should be considered potentially identical to delete p; since it can cause the object to be deleted. The pointer should NOT be used after an unref() unless it was known to be preceded by a ref(), or unless the count is checked prior to unref() and found to be > 1.
A new RCObject has a count of 0, and will only be destroyed automatically if the count goes from 1 back to 0, so the caller is in charge of it unless the first ref() call. Be careful storing these in std::unique_ptr! Instead, use a RCPtr(new RCObject()) in place of unique_ptr for hanging onto an RCOBject* in a local variable before possible early exit.
@TODO Consider adding a pointer to an abstract MemoryPool or what have you so that a Factory can implement the interface and these objects can be stored in a list as well as returned from factory. That way the factory can forcibly clear all dangling references from the pool in its dtor in the face of exception unwind or programmer ref counting error.
Definition at line 164 of file RCObject.h.
agg_util::RCObject::RCObject | ( | RCObjectPool * | pool = 0 | ) |
If the pool is given, the object will be released back to the pool when its count hits 0, otherwise it will be deleted.
agg_util::RCObject::RCObject | ( | const RCObject & | proto | ) |
Copy ctor: Starts count at 0 and adds us to the proto's pool if it exists.
void agg_util::RCObject::addPreDeleteCB | ( | UseCountHitZeroCB * | pCB | ) |
Add uniquely. If it is added agan, the second time is ignored.
|
virtual |
Get the current reference count
Implements agg_util::RCObjectInterface.
|
virtual |
Increase the reference count by one. const since we do not consider the ref count part of the semantic constness of the rep
Implements agg_util::RCObjectInterface.
|
virtual |
If the object is in an auto-delete pool, remove it from the pool and force it to only delete when it's ref count goes to 0. Useful when we desire a particular object stay around outside of the pool's lifetime.
Implements agg_util::RCObjectInterface.
void agg_util::RCObject::removePreDeleteCB | ( | UseCountHitZeroCB * | pCB | ) |
Remove it exists. If not, this unchanged.
|
virtual |
Just prints the count and address
Implements agg_util::RCObjectInterface.
Reimplemented in ncml_module::AggregationElement, ncml_module::AttributeElement, ncml_module::DimensionElement, ncml_module::ExplicitElement, ncml_module::NCMLElement, ncml_module::NetcdfElement, ncml_module::ReadMetadataElement, ncml_module::RemoveElement, ncml_module::ScanElement, ncml_module::ValuesElement, ncml_module::VariableAggElement, and ncml_module::VariableElement.
|
virtual |
Decrease the reference count by one. If it goes from 1 to 0, delete this and this is no longer valid.
It is illegal to unref() an object with a count of 0. We don't throw to allow use in dtors, so the caller is assumed not to do it!
const since the reference count is not part of the semantic constness of the rep
Implements agg_util::RCObjectInterface.
|
friend |
Definition at line 166 of file RCObject.h.