4#include <unordered_map>
14 template <
class DataType>
16 using Map = std::unordered_map<int, DataType>;
61 template <
class KeyType>
71 template <
class KeyType>
81 template <
class KeyType>
93 template <
class KeyType>
94 void put(DataType &&data) {
95 map[getTypeId<KeyType>()] = std::forward<DataType>(data);
104 template <
class KeyType>
106 static int id = LastTypeId++;
115 int size() {
return map.size(); }
118 static std::atomic_int LastTypeId;
122 template <
class ValueType>
123 std::atomic_int TypeMap<ValueType>::LastTypeId(0);
Map that has Types as key.
Definition: typemap.h:15
const_iterator begin() const
Return a const iterator to the beginning of this typemap.
Definition: typemap.h:28
void put(DataType &&data)
Place an item inside the map. If the map already contains this KeyType as a key, then replace the map...
Definition: typemap.h:94
const_iterator end() const
Return a const iterator to the end of this typemap.
Definition: typemap.h:36
iterator end()
Return an iterator to the end of this typemap.
Definition: typemap.h:52
Map::iterator iterator
Definition: typemap.h:18
int getTypeId()
Generate a unique ID for a type. Any call to this with the same type will return the same value.
Definition: typemap.h:105
iterator find()
Find a type inside this map.
Definition: typemap.h:62
Map::value_type value_type
Definition: typemap.h:20
iterator begin()
Return an iterator to the beginning of this typemap.
Definition: typemap.h:44
const_iterator find() const
Find a type inside this map.
Definition: typemap.h:72
int size()
Determine the number of mappings this map has.
Definition: typemap.h:115
bool hasKey()
Determine if the map already maps a type to some value.
Definition: typemap.h:82
Map::const_iterator const_iterator
Definition: typemap.h:19