Om
1.0.0
A universal framework for multimedia simulation
|
A class that implements a unique pointer that has a single owner. More...
#include <omUnique.h>
Public Member Functions | |
Unique () | |
Create a unique pointer object that is NULL. More... | |
Unique (T *newPointer) | |
Create a unique pointer object that wraps the specified raw pointer. More... | |
template<typename U > | |
Unique (U *newPointer) | |
Create a unique pointer object that wraps the specified raw pointer of a different type. More... | |
~Unique () | |
Release this Unique's reference to the object. More... | |
operator T * () const | |
Cast this Unique object to a raw pointer. More... | |
template<typename U > | |
operator U * () const | |
Cast this Unique object to a raw pointer of a different type to allow polymorphism. More... | |
Bool | operator== (const Unique &other) const |
Return whether or not this pointer is equal to another pointer. More... | |
template<typename U > | |
Bool | operator== (const Unique< U > &other) const |
Return whether or not this pointer is equal to another pointer. More... | |
Bool | operator!= (const Unique &other) const |
Return whether or not this pointer is not equal to another pointer. More... | |
template<typename U > | |
Bool | operator!= (const Unique< U > &other) const |
Return whether or not this pointer is not equal to another pointer. More... | |
T & | operator* () const |
Dereference the object referenced by this Unique. More... | |
T * | operator-> () const |
Overload the indirection operator so that this Unique object behaves like a raw pointer. More... | |
T * | getPointer () const |
Return a raw pointer to the object that this unique pointer references. More... | |
Bool | isNull () const |
Return whether or not this pointer is equal to NULL. More... | |
Bool | isSet () const |
Return whether or not this pointer is not equal to NULL. More... | |
operator Bool () const | |
Cast this pointer to a boolean value, indicating whether or not the pointer is NULL. More... | |
void | release () |
Destruct this pointer's object, resulting in a NULL unique pointer. More... | |
void | move (Unique< T > &unique) |
Transfer the ownership of this unique pointer to another one. More... | |
template<typename U > | |
U * | cast () const |
Cast this pointer to the template type using static_cast. More... | |
template<typename U > | |
U * | dynamicCast () const |
Cast this pointer to the template type using dynamic_cast. More... | |
A class that implements a unique pointer that has a single owner.
A unique pointer is used to encapsulate objects that should be allocated on the heap and have definite lifetime determined by a single owner. The object pointed to by the unique pointer is destructed when the unique pointer is destroyed. The unique pointer cannot be directly copied, since that would violate the semantics. The unique pointer does not add any overhead over a raw pointer.
|
inline |
Create a unique pointer object that is NULL.
|
inlineexplicit |
Create a unique pointer object that wraps the specified raw pointer.
By calling this constructor, the user acknowledges that the Unique object now owns the object pointed to by the raw pointer and will destroy it when the unique pointer object is destroyed.
newPointer | - the raw pointer which this Unique object should wrap. |
|
inlineexplicit |
Create a unique pointer object that wraps the specified raw pointer of a different type.
By calling this constructor, the user acknowledges that the Unique object now owns the object pointed to by the raw pointer and will destroy it when the unique pointer object is destroyed.
newPointer | - the raw pointer which this Unique object should wrap. |
|
inline |
Release this Unique's reference to the object.
|
inline |
Cast this Unique object to a raw pointer.
Cast this Unique object to a raw pointer of a different type to allow polymorphism.
|
inline |
Return whether or not this pointer is equal to another pointer.
This method compares the pointers themselves, not the objects pointed to by the pointers.
other | - the pointer to compare for equality. |
|
inline |
Return whether or not this pointer is equal to another pointer.
This method compares the pointers themselves, not the objects pointed to by the pointers.
other | - the pointer to compare for equality. |
|
inline |
Return whether or not this pointer is not equal to another pointer.
This method compares the pointers themselves, not the objects pointed to by the pointers.
other | - the pointer to compare for inequality. |
|
inline |
Return whether or not this pointer is not equal to another pointer.
This method compares the pointers themselves, not the objects pointed to by the pointers.
other | - the pointer to compare for inequality. |
|
inline |
|
inline |
|
inline |
Return a raw pointer to the object that this unique pointer references.
|
inline |
Return whether or not this pointer is equal to NULL.
|
inline |
Return whether or not this pointer is not equal to NULL.
|
inline |
Cast this pointer to a boolean value, indicating whether or not the pointer is NULL.
|
inline |
Destruct this pointer's object, resulting in a NULL unique pointer.
|
inline |
Transfer the ownership of this unique pointer to another one.
Cast this pointer to the template type using static_cast.
Cast this pointer to the template type using dynamic_cast.
If the cast was invalid and not able to performed, a NULL pointer is returned.