A reference to a BReferenceable object. More...
Public Member Functions | |
BReference () | |
Creates a reference without initializing it. | |
BReference (const BReference< Type > &other) | |
Copy constructor. | |
BReference (Type *object, bool alreadyHasReference=false) | |
Creates and initialize a reference. | |
~BReference () | |
Destructor. | |
Type * | Detach () |
Detach the pointed object from the reference. | |
Type * | Get () const |
Get the target object. | |
void | SetTo (Type *object, bool alreadyHasReference=false) |
Sets a new target for the reference. | |
void | Unset () |
Unsets the reference. | |
A reference to a BReferenceable object.
BReference simplifies the use of BReferenceable and makes it more transparent. It automatically acquires and release references to the pointed objects. It provides an API similar to a standard C++ pointer, allowing use of assignment and comparison operators and direct access to the object with -> and *.
|
inline |
Creates a reference without initializing it.
An uninitialized references behaves similarly to a NULL pointer.
|
inline |
Creates and initialize a reference.
The reference is set to the pointed object. If the parameter is set to true, the reference count is not incremented, this should only be used when referencing a freshly constructed object.
References BReference< Type >::SetTo().
|
inline |
Copy constructor.
The reference is set to the same object as the source. The reference count of the target object is incremented.
References BReference< Type >::Get(), and BReference< Type >::SetTo().
|
inline |
Destructor.
The reference count of the target object is decremented.
References BReference< Type >::Unset().
|
inline |
Detach the pointed object from the reference.
This returns the pointed object and unsets the reference, without decrementing the object reference count. It is used to transfer ownership of the reference to something else.
References NULL.
|
inline |
Get the target object.
Referenced by BReference< Type >::BReference().
|
inline |
Sets a new target for the reference.
The reference to the previously targetted object is released. A reference to the new object is acquired only if alreadyHasReference
is false.
References NULL, and BReference< Type >::Unset().
Referenced by BReference< Type >::BReference().
|
inline |
Unsets the reference.
The targetted object is released. The reference is unset and can't be used to access it anymore.
References NULL.
Referenced by BReference< Type >::~BReference(), and BReference< Type >::SetTo().