class Ref
MyCpp::Ref

Ref objects provide a convinient method for managing Referenced objects.

A Ref object holds a reference to a Referenced object. The object is "grabbed" (by calling the grab method), when the reference is associated with that object, and the object is "unrefed" (by calling the unref method) when the Ref is destroyed, or when it gets associated to another object.

Methods
T*
ptr () const
Returns a pointer to associated object.
bool
isNull ()
Tells whether the Ref is associated with any object.
operator T* () const
Converts Ref to a pointer to associated object.
T*
operator -> () const
Allows to use the Ref object as a pointer to associated object.
T&
operator * () const
Dereferences Ref, providing a C++ reference to associated object.
Ref&
operator = (const Ref &ref)
Makes an object associated with ref being associated this Ref also.
Ref&
operator = (T *obj)
Associates object obj with this Ref.
Ref&
operator = (T &obj)
Associates object obj with this Ref.
Ref (const Ref &ref)
Makes a copy of ref.
Ref (T *obj)
Creates a Ref, and associates it with obj.
Ref (T &obj)
Creates a Ref, and associates it with obj.
Ref ()
Creates a null Ref.
ptr

Returns a pointer to associated object.

If the Ref is not (yet) assinged to any object, then NULL is returned.

T* ptr () const
isNull

Tells whether the Ref is associated with any object.

Returns true, if this Ref is associated with an object, otherwise returns false.

bool isNull ()
operator T*

Converts Ref to a pointer to associated object.

Returns NULL, if there is no object associated with this Ref.

operator T* () const
operator ->

Allows to use the Ref object as a pointer to associated object.

Generally, one should not use this operator, if there is no associated object for this Ref.

T* operator -> () const
operator *

Dereferences Ref, providing a C++ reference to associated object.

One must not use this operation, if there is no associated object fot this Ref.

T& operator * () const
operator =

Makes an object associated with ref being associated this Ref also.

Ref& operator = (const Ref &ref)
operator =

Associates object obj with this Ref.

If obj is NULL, then this Ref becomes a null reference.

Ref& operator = (T *obj)
operator =

Associates object obj with this Ref.

Ref& operator = (T &obj)
Ref

Makes a copy of ref.

After completion, the object associated with ref is also associated with the returned Ref.

Ref (const Ref &ref)
Ref

Creates a Ref, and associates it with obj.

Ref (T *obj)
Ref

Creates a Ref, and associates it with obj.

Ref (T &obj)
Ref

Creates a null Ref.

Ref ()