Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Public Member Functions | List of all members
gf::Handle Class Reference

A handle to an object or an id. More...

#include <gf/Handle.h>

Public Member Functions

 Handle ()=default
 Default constructor. More...
 
 Handle (Id id)
 Constructor with an id. More...
 
template<typename T >
 Handle (T &object)
 Coonstructor with an object. More...
 
Id asId () const
 Get the contained id. More...
 
template<typename T >
T & as ()
 Get the reference to the object. More...
 
template<typename T >
const T & as () const
 Get the reference to the object. More...
 

Detailed Description

A handle to an object or an id.

A handle is a very light container around either an id or a reference to an object. No type checking is made, it's up to the user to know what to do with this handle.

Constructor & Destructor Documentation

◆ Handle() [1/3]

gf::Handle::Handle ( )
default

Default constructor.

◆ Handle() [2/3]

gf::Handle::Handle ( Id  id)
inlineexplicit

Constructor with an id.

◆ Handle() [3/3]

template<typename T >
gf::Handle::Handle ( T &  object)
inlineexplicit

Coonstructor with an object.

Member Function Documentation

◆ as() [1/2]

template<typename T >
T & gf::Handle::as ( )
inline

Get the reference to the object.

◆ as() [2/2]

template<typename T >
const T & gf::Handle::as ( ) const
inline

Get the reference to the object.

◆ asId()

Id gf::Handle::asId ( ) const
inline

Get the contained id.

Member Data Documentation

◆ m_id

Id gf::Handle::m_id

◆ m_ptr

void* gf::Handle::m_ptr