Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::FlyWeight< Key, Value > Class Template Reference

Flyweight pattern implementation that stores shared objects keyed by a unique identifier. More...

#include <aeongames/FlyWeight.hpp>

Collaboration diagram for AeonGames::FlyWeight< Key, Value >:
Collaboration graph

Classes

class  Handle
 Lightweight handle providing read-only access to a packed FlyWeight object. More...

Public Member Functions

const Handle Pack (const Key &aKey)
 Register this object in the store with the given key.
void Unpack ()
 Remove this object from the store and reset its key.
const Handle GetHandle () const
 Obtain a Handle to this packed object.

Detailed Description

template<class Key, class Value>
class AeonGames::FlyWeight< Key, Value >

Flyweight pattern implementation that stores shared objects keyed by a unique identifier.

Template Parameters
KeyThe type used as a unique identifier for stored objects.
ValueThe derived type that inherits from FlyWeight.

Definition at line 29 of file FlyWeight.hpp.

Member Function Documentation

◆ GetHandle()

template<class Key, class Value>
const Handle AeonGames::FlyWeight< Key, Value >::GetHandle ( ) const
inline

Obtain a Handle to this packed object.

Returns
A Handle for the current key.
Exceptions
std::runtime_errorif the object is not packed.

Definition at line 194 of file FlyWeight.hpp.

◆ Pack()

template<class Key, class Value>
const Handle AeonGames::FlyWeight< Key, Value >::Pack ( const Key & aKey)
inline

Register this object in the store with the given key.

Parameters
aKeyThe unique key to associate with this object.
Returns
A Handle to the packed object.
Exceptions
std::runtime_errorif aKey is null/empty or already in use.

Definition at line 165 of file FlyWeight.hpp.

◆ Unpack()

template<class Key, class Value>
void AeonGames::FlyWeight< Key, Value >::Unpack ( )
inline

Remove this object from the store and reset its key.

Definition at line 183 of file FlyWeight.hpp.


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