FX::FXRefingObject< type > Class Template Reference

#include <FXRefedObject.h>

Inheritance diagram for FX::FXRefingObject< type >:

FX::FXRefingObjectBase FX::Generic::ptr< type, ownershipPolicy > List of all members.

Detailed Description

template<class type>
class FX::FXRefingObject< type >

A handle to a reference counted object.

Parameters:
type The type of the data to be reference counted. This must inherit FX::FXRefedObject
FX::FXRefingObject and FX::FXRefedObject are a pair of classes which denote a handle and reference counted object respectively. The basic premise is that a FXRefedObject subclass maintains a count incremented by the construction of a corresponding FXRefingObject pointing to it and decremented by the same's destruction. If the count reaches zero, the virtual method FX::FXRefedObject::noMoreReferrers() is called which typically deletes the object.

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();
}
In addition to the usual 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.

See also:
FX::FXRefedObject, FX::FXLRUCache

Definition at line 413 of file FXRefedObject.h.

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)


The documentation for this class was generated from the following file:
(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:35:54 2009 for TnFOX by doxygen v1.4.7