#include <Ref.h>
Collaboration diagram for Ref< T >:
Objects used with this reference class have to be descandents of class Referable.
sample usage:
include "Ref.h" include "Referable.h"
class A : public virtual Referable;
...
A * a = new A(); Ref ref1 = a; // 1 reference to a Ref ref2 = ref1; // 2 references to a
ref1 = 0; // 1 reference to a ref2 = 0; // at this point object a is destroyed
Based on Tima Saarinen's work, http://gamma.nic.fi/~timosa/comp/refcount.html
Definition at line 82 of file Ref.h.
Public Member Functions | |
Ref (void) throw () | |
Default constructor. | |
Ref (const Ref< T > &other) throw ( Exception ) | |
Copy constructor. | |
Ref (T *obj) throw ( Exception ) | |
Constructor based on an object to reference. | |
virtual | ~Ref (void) throw ( Exception ) |
Destructor. | |
T * | operator-> () const throw ( Exception ) |
Operator overload to make the reference seem like a pointer. | |
Ref< T > & | operator= (Ref< T > other) throw ( Exception ) |
Assignment operator. | |
Ref< T > & | operator= (T *obj) throw ( Exception ) |
Assignment operator. | |
void | set (T *newobj) throw ( Exception ) |
Set the object referenced. | |
T * | get (void) const throw () |
Return object pointer. | |
bool | operator== (const T *other) const throw () |
Equality operator. | |
bool | operator== (const Ref< T > &other) const throw () |
Equality operator. | |
bool | operator!= (const T *other) const throw () |
Unequality operator. | |
bool | operator!= (const Ref< T > &other) const throw () |
Unequality operator. |
|
Default constructor.
|
|
Copy constructor.
|
|
Constructor based on an object to reference.
|
|
Destructor.
|
|
Return object pointer. This method should be used with care because it breaks the encapsulation. Typically this method is needed for the method calls which require literal object pointer. It may not be bad idea to pass the Ref objects as method arguments.
Definition at line 230 of file Ref.h. Referenced by Connector::attach(), CastSink::getSink(), and MultiThreadedConnector::sinkThread(). |
|
Unequality operator.
|
|
Unequality operator.
|
|
Operator overload to make the reference seem like a pointer.
|
|
Assignment operator.
|
|
Assignment operator.
|
|
Equality operator.
|
|
Equality operator.
|
|
Set the object referenced. Deletes the old referenced object is this was it's last reference.
Definition at line 195 of file Ref.h. Referenced by Ref< FileSink >::operator=(), Ref< FileSink >::Ref(), and Ref< FileSink >::~Ref(). |