#include <FXRefedObject.h>
type | The type of the data to be reference counted. This must inherit FX::FXRefedObject |
In v0.6 of TnFOX the old implementation of this taken from Tornado was replaced with a much superior version based on FX::Generic::ptr. This has enabled a much greater degree of self-determination - now FXRefingObject configures itself automatically according to how you configure its FXRefedObject - you no longer need to reproduce the policies. Also when type inherits a FX::QMutex that mutex is automatically locked around modifications to the referrers list if enabled.
The basic form is as follows:
class Foo : public FXRefedObject<FXAtomicInt>, public QMutex { bool foo(); }; typedef FXRefingObject<Foo> FooHold; ... bool f(Foo *f) { FooHold fh(f); return fh->foo(); }
PtrPtr()
, PtrRef()
, PtrRelease()
and PtrReset()
helper functions there is a PtrDetach()
which returns a handle referring to a new
copy constructed instance of the pointee.FXRefingObject can work with FX::FXLRUCache to implement a LRU caching system of reference counted objects.
Public Member Functions | |
FXRefingObject (type *data=0, const char *file=0, int lineno=0) | |
FXRefingObject (FXAutoPtr< type > &ptr) | |
FXRefingObject (const FXRefingObject &o, const char *file=0, int lineno=0) | |
const char * | int_allocated_file () const throw () |
int | int_allocated_lineno () const throw () |
type & | operator* () |
const type & | operator* () const |
type * | operator-> () |
const type * | operator-> () const |
template<typename T> | |
bool | operator== (const ptr< T > &o) const |
template<typename T> | |
bool | operator== (T *o) const |
operator Tester * () const | |
bool | operator! () const |
template<typename T> | |
bool | operator!= (const ptr< T > &o) const |
template<typename T> | |
bool | operator!= (T *o) const |
Friends | |
FXRefingObject | PtrDetach (FXRefingObject &p) |
type * | PtrRelease (ptr &p) |
void | PtrReset (ptr &p, type *data) |
FX::FXRefingObject< type >::FXRefingObject | ( | type * | data = 0 , |
|
const char * | file = 0 , |
|||
int | lineno = 0 | |||
) | [inline] |
Constructs an instance holding a reference to data.
FXRefingObject PtrDetach | ( | FXRefingObject< type > & | p | ) | [friend] |
Makes a copy of the referenced object and returns a holder pointing to the new copy
type* PtrRelease | ( | ptr< type, ownershipPolicy > & | p | ) | [friend, inherited] |
Releases the pointer (sets it to zero, returns the former contents).
void PtrReset | ( | ptr< type, ownershipPolicy > & | p, | |
type * | data | |||
) | [friend, inherited] |
Resets the pointer (deletes the old contents, sets to new contents).
Referenced by FX::Generic::ptr< FX::TnFXSQLDBCursor, FX::FXRefingObjectImpl::refedObject< type > >::operator=().