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

Core class that represents a object handle. More...

Public Member Functions

 ObjectHandle ()
 Constructs a ObjectHandle object by default.
 
 ObjectHandle (T *object)
 Constructs a ObjectHandle object with a pointer to an object. More...
 
 ObjectHandle (const ObjectHandle &handle)
 Constructs a ObjectHandle object by assignation. More...
 
 ObjectHandle (ObjectHandle &&handle) noexcept
 Constructs a ObjectHandle object by move semantic. More...
 
 ~ObjectHandle ()
 Destructs the object and calls reset with nullptr. More...
 
T * GetObject () const
 Gets the underlying object. More...
 
bool IsValid () const
 Checks whether the object is valid. More...
 
void Reset (T *object=nullptr)
 Resets the content of the ObjectHandle with another object. More...
 
void Reset (const ObjectHandle &handle)
 Resets the content of this with another object. More...
 
void Reset (ObjectHandle &&handle) noexcept
 Resets the content of this with another object by move semantic. More...
 
ObjectHandleSwap (ObjectHandle &handle)
 Swaps the content of the two ObjectHandle. More...
 
Nz::String ToString () const
 Gives a string representation. More...
 
 operator bool () const
 Converts the ObjectHandle to bool. More...
 
 operator T* () const
 Dereferences the ObjectHandle. More...
 
T * operator-> () const
 Dereferences the ObjectHandle. More...
 
ObjectHandleoperator= (T *object)
 Assigns the entity into this. More...
 
ObjectHandleoperator= (const ObjectHandle &handle)
 Sets the handle of the ObjectHandle with the handle from another. More...
 
ObjectHandleoperator= (ObjectHandle &&handle) noexcept
 Moves the ObjectHandle into this. More...
 

Static Public Attributes

static const ObjectHandle InvalidHandle
 

Protected Member Functions

void OnObjectDestroyed ()
 Action to do on object destruction.
 
void OnObjectMoved (T *newObject)
 Action to do on object move.
 

Protected Attributes

T * m_object
 

Detailed Description

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

Core class that represents a object handle.

Constructor & Destructor Documentation

◆ ObjectHandle() [1/3]

template<typename T>
Nz::ObjectHandle< T >::ObjectHandle ( T *  object)
explicit

Constructs a ObjectHandle object with a pointer to an object.

Parameters
objectPointer to handle like an object (can be nullptr)

◆ ObjectHandle() [2/3]

template<typename T>
Nz::ObjectHandle< T >::ObjectHandle ( const ObjectHandle< T > &  handle)

Constructs a ObjectHandle object by assignation.

Parameters
handleObjectHandle to assign into this

◆ ObjectHandle() [3/3]

template<typename T>
Nz::ObjectHandle< T >::ObjectHandle ( ObjectHandle< T > &&  handle)
noexcept

Constructs a ObjectHandle object by move semantic.

Parameters
handleObjectHandle to move into this

◆ ~ObjectHandle()

template<typename T >
Nz::ObjectHandle< T >::~ObjectHandle ( )

Destructs the object and calls reset with nullptr.

See also
Reset

Member Function Documentation

◆ GetObject()

template<typename T >
T * Nz::ObjectHandle< T >::GetObject ( ) const

Gets the underlying object.

Returns
Underlying object

◆ IsValid()

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

Checks whether the object is valid.

Returns
true if object is not nullptr

◆ operator bool()

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

Converts the ObjectHandle to bool.

Returns
true if reference is not nullptr
See also
IsValid

◆ operator T*()

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

Dereferences the ObjectHandle.

Returns
Underlying pointer

◆ operator->()

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

Dereferences the ObjectHandle.

Returns
Underlying pointer

◆ operator=() [1/3]

template<typename T>
ObjectHandle< T > & Nz::ObjectHandle< T >::operator= ( T *  entity)

Assigns the entity into this.

Returns
A reference to this
Parameters
entityPointer to handle like an object (can be nullptr)

◆ operator=() [2/3]

template<typename T>
ObjectHandle< T > & Nz::ObjectHandle< T >::operator= ( const ObjectHandle< T > &  handle)

Sets the handle of the ObjectHandle with the handle from another.

Returns
A reference to this
Parameters
handleThe other ObjectHandle

◆ operator=() [3/3]

template<typename T>
ObjectHandle< T > & Nz::ObjectHandle< T >::operator= ( ObjectHandle< T > &&  handle)
noexcept

Moves the ObjectHandle into this.

Returns
A reference to this
Parameters
handleObjectHandle to move in this

◆ Reset() [1/3]

template<typename T>
void Nz::ObjectHandle< T >::Reset ( T *  object = nullptr)

Resets the content of the ObjectHandle with another object.

Parameters
objectObject to handle

◆ Reset() [2/3]

template<typename T>
void Nz::ObjectHandle< T >::Reset ( const ObjectHandle< T > &  handle)

Resets the content of this with another object.

Parameters
handleNew object to handle

◆ Reset() [3/3]

template<typename T>
void Nz::ObjectHandle< T >::Reset ( ObjectHandle< T > &&  handle)
noexcept

Resets the content of this with another object by move semantic.

Parameters
handleNew object to handle to move into this

◆ Swap()

template<typename T >
ObjectHandle< T > & Nz::ObjectHandle< T >::Swap ( ObjectHandle< T > &  handle)

Swaps the content of the two ObjectHandle.

Returns
A reference to this
Parameters
handleObjectHandle to swap

◆ ToString()

template<typename T >
Nz::String Nz::ObjectHandle< T >::ToString ( ) const

Gives a string representation.

Returns
A string representation of the object "ObjectHandle(object representation) or Null"

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