template<typename ValueType, typename Id = MxString, typename ValueStorage = MxHashMap<Id, ValueType>, typename IdStorage = MxVector<Id>>
class MxEngine::LifetimeManager< ValueType, Id, ValueStorage, IdStorage >
lifetime manager is a generic class which stores elements using their unique ids. It supports lazy invokation (i.e. deleting K elements event from vector with N elements will still be O(N), not (K*N)) Note that before getting element it should be checked for Existance using Exist() or call Update() to invalidate cache. For performance reasons functions like GetElements does not invalidate cache, so be careful with them and do not suppose recently added object is already in list In general, you want to write something like LifetimeManager<GameObject, UUID> to create manager, but you also can specify storage and cache containers as well
template<typename ValueType , typename Id = MxString, typename ValueStorage = MxHashMap<Id, ValueType>, typename IdStorage = MxVector<Id>>
template<typename IdT , typename ValueT >
adds new object to the storage. If object with same id already present, it will be replaced. Note that all additions are stored in cache until Update() method is being called
- Parameters
-
| key | unique object identifier |
| value | object itself |
template<typename ValueType , typename Id = MxString, typename ValueStorage = MxHashMap<Id, ValueType>, typename IdStorage = MxVector<Id>>
template<typename IdT >
removes object from the storage by id. If object with that id does not exists, no action is performed Note that all removals are stored in cache until Update() method is being called
- Parameters
-
| key | unique object identifier to remove |
template<typename ValueType , typename Id = MxString, typename ValueStorage = MxHashMap<Id, ValueType>, typename IdStorage = MxVector<Id>>
invalidates caches, resulting in new object addition and deleting of requested once if object with same ID is added and deleted before update, firstly manager will try to delete id from storage, then add new object