Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::Archive< K, T > Class Template Reference

Key-value archive that owns stored objects of type T, keyed by K. More...

#include <aeongames/Archive.hpp>

Collaboration diagram for AeonGames::Archive< K, T >:
Collaboration graph

Public Member Functions

template<typename... Args>
T * Store (const K &k, Args... args)
 Construct and store a new object under the given key.
T * Store (const K &k, std::unique_ptr< T > &&pointer)
 Store an existing uniquely-owned object under the given key.
std::unique_ptr< T > Dispose (const K &k)
 Remove and return the object associated with the given key.
const T * Get (const K &k) const
 Retrieve a stored object by key (const).
T * Get (const K &k)
 Retrieve a stored object by key (mutable).
const K & GetKey (const T *t) const
 Find the key associated with a stored object.

Detailed Description

template<class K, class T>
class AeonGames::Archive< K, T >

Key-value archive that owns stored objects of type T, keyed by K.

Template Parameters
KKey type (must be hashable).
TValue type.

Definition at line 32 of file Archive.hpp.

Member Function Documentation

◆ Dispose()

template<class K, class T>
std::unique_ptr< T > AeonGames::Archive< K, T >::Dispose ( const K & k)
inline

Remove and return the object associated with the given key.

Parameters
kKey of the object to dispose.
Returns
Unique pointer to the removed object, or nullptr if not found.

Definition at line 64 of file Archive.hpp.

◆ Get() [1/2]

template<class K, class T>
T * AeonGames::Archive< K, T >::Get ( const K & k)
inline

Retrieve a stored object by key (mutable).

Parameters
kKey to look up.
Returns
Pointer to the object, or nullptr if not found.

Definition at line 94 of file Archive.hpp.

◆ Get() [2/2]

template<class K, class T>
const T * AeonGames::Archive< K, T >::Get ( const K & k) const
inline

Retrieve a stored object by key (const).

Parameters
kKey to look up.
Returns
Pointer to the object, or nullptr if not found.

Definition at line 80 of file Archive.hpp.

◆ GetKey()

template<class K, class T>
const K & AeonGames::Archive< K, T >::GetKey ( const T * t) const
inline

Find the key associated with a stored object.

Parameters
tPointer to the object to look up.
Returns
Const reference to the key.
Exceptions
std::runtime_errorif the object is not found.

Definition at line 104 of file Archive.hpp.

◆ Store() [1/2]

template<class K, class T>
template<typename... Args>
T * AeonGames::Archive< K, T >::Store ( const K & k,
Args... args )
inline

Construct and store a new object under the given key.

Template Parameters
ArgsConstructor argument types.
Parameters
kKey to associate with the new object.
argsArguments forwarded to the T constructor.
Returns
Raw pointer to the stored object.

Definition at line 43 of file Archive.hpp.

◆ Store() [2/2]

template<class K, class T>
T * AeonGames::Archive< K, T >::Store ( const K & k,
std::unique_ptr< T > && pointer )
inline

Store an existing uniquely-owned object under the given key.

Parameters
kKey to associate with the object.
pointerUnique pointer to the object to store (moved).
Returns
Raw pointer to the stored object.

Definition at line 54 of file Archive.hpp.


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