utility to store and request pointers, and to delete dynamically allocated objects, by name
More...
#include <assetmanager.h>
|
| | ~AssetManager () |
| |
| template<class T > |
| bool | insert (std::string name, T *obj) |
| | insert pointer. if it exists (same type T and same name), previous object is deleted and the pointer is replaced. rejects nullptrs.
|
| |
| template<class T > |
| void | insert (std::string name, T obj) |
| | dummy for compile-time check (static_assert) of non-pointer type
|
| |
| template<class T > |
| T * | get (std::string name) |
| | request pointer by name
|
| |
| template<class T > |
| size_t | numOf () |
| | returns number of stored pointers of type T*
|
| |
| template<class T > |
| void | destroy (std::string name) |
| | destroy (delete) object, remove pointer
|
| |
| template<class T > |
| void | destroy () |
| | destroy (delete) all objects of type T, remove all pointers of type T*
|
| |
| void | clear () |
| | clear content. delete all objects, remove all pointers
|
| |
utility to store and request pointers, and to delete dynamically allocated objects, by name
use like so:
- create an object with
new
- use insert() to store the pointer by name
- if it exists, previous object is deleted and the pointer is replaced
- use get() to request the pointer by name
- use destroy() to delete the object and remove the pointer by name
- Attention
- type T is always the base type, not the pointer type (T*)
-
never delete objects manually with
delete if they have been stored with insert()
◆ ~AssetManager()
| yourgame::util::AssetManager::~AssetManager |
( |
| ) |
|
|
inline |
◆ clear()
| void yourgame::util::AssetManager::clear |
( |
| ) |
|
|
inline |
clear content. delete all objects, remove all pointers
◆ destroy() [1/2]
template<class T >
| void yourgame::util::AssetManager::destroy |
( |
| ) |
|
|
inline |
destroy (delete) all objects of type T, remove all pointers of type T*
- Template Parameters
-
◆ destroy() [2/2]
template<class T >
| void yourgame::util::AssetManager::destroy |
( |
std::string |
name | ) |
|
|
inline |
destroy (delete) object, remove pointer
- Template Parameters
-
- Parameters
-
◆ get()
template<class T >
| T * yourgame::util::AssetManager::get |
( |
std::string |
name | ) |
|
|
inline |
request pointer by name
- Template Parameters
-
- Parameters
-
- Returns
- pointer. nullptr, if no pointer of type T* and name exists
◆ insert() [1/2]
template<class T >
| bool yourgame::util::AssetManager::insert |
( |
std::string |
name, |
|
|
T * |
obj |
|
) |
| |
|
inline |
insert pointer. if it exists (same type T and same name), previous object is deleted and the pointer is replaced. rejects nullptrs.
- Attention
- obj must be a pointer type
-
only insert pointer to object, that has been created with
new
- Template Parameters
-
- Parameters
-
- Returns
- false, if obj was nullptr, true otherwise
◆ insert() [2/2]
template<class T >
| void yourgame::util::AssetManager::insert |
( |
std::string |
name, |
|
|
T |
obj |
|
) |
| |
|
inline |
dummy for compile-time check (static_assert) of non-pointer type
- Template Parameters
-
- Parameters
-
◆ numOf()
template<class T >
| size_t yourgame::util::AssetManager::numOf |
( |
| ) |
|
|
inline |
returns number of stored pointers of type T*
- Template Parameters
-
- Returns
- number of stored pointers of type T*
The documentation for this class was generated from the following file: