#include "DataMap.h"
|
template<class T > |
T * | Get (std::string const &k) const |
|
template<class T , typename std::enable_if< std::is_default_constructible< T >::value, int >::type = 0> |
T * | GetDefault (std::string const &k) |
|
void | Set (std::string const &k, Base *v) |
|
bool | Erase (std::string const &k) |
|
|
std::unordered_map< std::string, std::unique_ptr< Base > > | Container |
|
◆ Erase()
bool DataMap::Erase |
( |
std::string const & |
k | ) |
|
|
inline |
Removes objects with given key and returns true if one was removed, false otherwise
std::unordered_map< std::string, std::unique_ptr< Base > > Container
Definition DataMap.h:73
References Container.
◆ Get()
template<class T >
T * DataMap::Get |
( |
std::string const & |
k | ) |
const |
|
inline |
Returns a pointer to object of requested type stored with given key or nullptr
30 {
31 static_assert(std::is_base_of<Base, T>::value, "T must derive from Base");
33 {
34 return nullptr;
35 }
36
39 {
40 return dynamic_cast<T*>(it->second.get());
41 }
42 return nullptr;
43 }
References Container.
◆ GetDefault()
template<class T , typename std::enable_if< std::is_default_constructible< T >::value, int >::type = 0>
T * DataMap::GetDefault |
( |
std::string const & |
k | ) |
|
|
inline |
Returns a pointer to object of requested type stored with given key or default constructs one and returns that one
51 {
52 static_assert(std::is_base_of<Base, T>::value, "T must derive from Base");
53 if (T* v = Get<T>(k))
54 {
55 return v;
56 }
57 T* v = new T();
58 Container.emplace(k, std::unique_ptr<T>(v));
59 return v;
60 }
References Container.
◆ Set()
void DataMap::Set |
( |
std::string const & |
k, |
|
|
Base * |
v |
|
) |
| |
|
inline |
Stores a new object that inherits the Base class with the given key
65{
Container[k] = std::unique_ptr<Base>(v); }
References Container.
◆ Container
std::unordered_map<std::string, std::unique_ptr<Base> > DataMap::Container |
|
private |
The documentation for this class was generated from the following file:
- azerothcore-wotlk/src/common/Utilities/DataMap.h