Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::ObjectRef< T > Class Template Reference

Core class that represents a reference to an object. More...

Public Member Functions

 ObjectRef ()
 Constructs a ObjectRef object by default.
 
 ObjectRef (T *object)
 Constructs a ObjectRef object with a pointer to an object. More...
 
 ObjectRef (const ObjectRef &ref)
 Constructs a ObjectRef object by assignation. More...
 
template<typename U >
 ObjectRef (const ObjectRef< U > &ref)
 Constructs a ObjectRef<U> object from another type of ObjectRef. More...
 
 ObjectRef (ObjectRef &&ref) noexcept
 Constructs a ObjectRef object by move semantic. More...
 
 ~ObjectRef ()
 Destructs the object (remove a reference to the object when shared)
 
T * Get () const
 Gets the underlying pointer. More...
 
bool IsValid () const
 Checks whether the reference is valid. More...
 
T * Release ()
 Releases the handle of the pointer. More...
 
bool Reset (T *object=nullptr)
 Resets the content of the ObjectRef with another pointer. More...
 
ObjectRefSwap (ObjectRef &ref)
 Swaps the content of the two ObjectRef. More...
 
 operator bool () const
 Converts the ObjectRef to bool. More...
 
 operator T* () const
 Dereferences the ObjectRef. More...
 
T * operator-> () const
 Dereferences the ObjectRef. More...
 
ObjectRefoperator= (T *object)
 Assigns the object into this. More...
 
ObjectRefoperator= (const ObjectRef &ref)
 Sets the reference of the ObjectRef with the handle from another. More...
 
template<typename U >
ObjectRefoperator= (const ObjectRef< U > &ref)
 
ObjectRefoperator= (ObjectRef &&ref) noexcept
 Moves the ObjectRef into this. More...
 
template<typename U >
ObjectRef< T > & operator= (const ObjectRef< U > &ref)
 Sets the reference of the ObjectRef from another type of ObjectRef. More...
 

Detailed Description

template<typename T>
class Nz::ObjectRef< T >

Core class that represents a reference to an object.

Constructor & Destructor Documentation

◆ ObjectRef() [1/4]

template<typename T>
Nz::ObjectRef< T >::ObjectRef ( T *  object)

Constructs a ObjectRef object with a pointer to an object.

Parameters
objectPointer to handle like a reference (can be nullptr)

◆ ObjectRef() [2/4]

template<typename T>
Nz::ObjectRef< T >::ObjectRef ( const ObjectRef< T > &  ref)

Constructs a ObjectRef object by assignation.

Parameters
refObjectRef to assign into this

◆ ObjectRef() [3/4]

template<typename T >
template<typename U >
Nz::ObjectRef< T >::ObjectRef ( const ObjectRef< U > &  ref)

Constructs a ObjectRef<U> object from another type of ObjectRef.

Parameters
refObjectRef of type U to convert to type T

◆ ObjectRef() [4/4]

template<typename T>
Nz::ObjectRef< T >::ObjectRef ( ObjectRef< T > &&  ref)
noexcept

Constructs a ObjectRef object by move semantic.

Parameters
refObjectRef to move into this

Member Function Documentation

◆ Get()

template<typename T >
T * Nz::ObjectRef< T >::Get ( ) const

Gets the underlying pointer.

Returns
Underlying pointer

◆ IsValid()

template<typename T >
bool Nz::ObjectRef< T >::IsValid ( ) const

Checks whether the reference is valid.

Returns
true if reference is not nullptr

◆ operator bool()

template<typename T >
Nz::ObjectRef< T >::operator bool ( ) const
explicit

Converts the ObjectRef to bool.

Returns
true if reference is not nullptr
See also
IsValid

◆ operator T*()

template<typename T >
Nz::ObjectRef< T >::operator T* ( ) const

Dereferences the ObjectRef.

Returns
Underlying pointer

◆ operator->()

template<typename T >
T * Nz::ObjectRef< T >::operator-> ( ) const

Dereferences the ObjectRef.

Returns
Underlying pointer

◆ operator=() [1/4]

template<typename T>
ObjectRef< T > & Nz::ObjectRef< T >::operator= ( T *  object)

Assigns the object into this.

Returns
A reference to this
Parameters
objectPointer to handle like a reference (can be nullptr)

◆ operator=() [2/4]

template<typename T>
ObjectRef< T > & Nz::ObjectRef< T >::operator= ( const ObjectRef< T > &  ref)

Sets the reference of the ObjectRef with the handle from another.

Returns
A reference to this
Parameters
refThe other ObjectRef

◆ operator=() [3/4]

template<typename T>
ObjectRef< T > & Nz::ObjectRef< T >::operator= ( ObjectRef< T > &&  ref)
noexcept

Moves the ObjectRef into this.

Returns
A reference to this
Parameters
refObjectRef to move in this

◆ operator=() [4/4]

template<typename T>
template<typename U >
ObjectRef<T>& Nz::ObjectRef< T >::operator= ( const ObjectRef< U > &  ref)

Sets the reference of the ObjectRef from another type of ObjectRef.

Returns
A reference to this
Parameters
refObjectRef of type U to convert

◆ Release()

template<typename T >
T * Nz::ObjectRef< T >::Release ( )

Releases the handle of the pointer.

Returns
Underlying pointer

◆ Reset()

template<typename T>
bool Nz::ObjectRef< T >::Reset ( T *  object = nullptr)

Resets the content of the ObjectRef with another pointer.

Returns
true if old handle is destroyed

◆ Swap()

template<typename T >
ObjectRef< T > & Nz::ObjectRef< T >::Swap ( ObjectRef< T > &  ref)

Swaps the content of the two ObjectRef.

Returns
A reference to this
Parameters
refObjectRef to swap

The documentation for this class was generated from the following files: