10 #ifndef EMP_DATA_MANAGER_H 11 #define EMP_DATA_MANAGER_H 16 #include "../base/assert.h" 17 #include "../tools/map_utils.h" 24 template <
typename VAL_TYPE,
emp::data... MODS>
27 using data_t = VAL_TYPE;
30 std::map<std::string, node_t *> node_map;
35 for (
auto & x : node_map)
delete x.second;
39 size_t GetSize()
const {
return node_map.size(); }
44 return Has(node_map, name);
50 node_map[name] =
new node_t;
51 return *(node_map[name]);
56 void Delete(
const std::string & name) {
63 const node_t &
Get(
const std::string & name)
const {
65 return *(node_map[name]);
72 return *(node_map[name]);
87 template <
typename... Ts>
88 void AddData(
const std::string & name, Ts... extra) {
90 node_map[name]->Add(extra...);
98 for (
auto & x : node_map) x.second->Reset();
void Delete(const std::string &name)
Definition: DataManager.h:56
DataNode objects track a specific type of data over the course of a run.
void AddData(const std::string &name, Ts...extra)
Definition: DataManager.h:88
DataManager()
Definition: DataManager.h:33
DataManagers handle sets of DataNode objects that all have the same tracking settings.
Definition: DataManager.h:25
node_t & New(const std::string &name)
Creates and adds a new DataNode, with the name specified in.
Definition: DataManager.h:48
data
A set of modifiers are available do describe DataNode.
Definition: DataNode.h:38
Definition: DataNode.h:648
void ResetAll()
Definition: DataManager.h:97
~DataManager()
Definition: DataManager.h:34
bool Has(const MAP_T &in_map, const KEY_T &key)
Take any map type, and run find to determine if a key is present.
Definition: map_utils.h:21
If we are in emscripten, make sure to include the header.
Definition: array.h:37
auto & GetNodes() const
Returns the std::map mapping node names (strings) to DataNodes.
Definition: DataManager.h:41
#define emp_assert(...)
Definition: assert.h:199
node_t & Get(const std::string &name)
Definition: DataManager.h:70
size_t GetSize() const
Returns the number of DataNodes in this DataManager.
Definition: DataManager.h:39
const node_t & Get(const std::string &name) const
Definition: DataManager.h:63
bool HasNode(const std::string &name)
Definition: DataManager.h:43