10class DataComponent :
public Component
22 void setEntry(
const std::string& key,
const T& value) { dataMap.insert_or_assign(key, value); }
31 std::optional<T>
getEntry(std::string key)
const {
32 if (!this->dataMap.contains(key))
return std::nullopt;
33 const std::any& value = this->dataMap.at(key);
34 if (value.type() !=
typeid(T)) {
return std::nullopt; }
35 return std::any_cast<T>(value);
38 std::map<std::string, std::any> dataMap;
void setEntry(const std::string &key, const T &value)
Set a key-value pair of any type in the data map.
Definition DataComponent.h:22
std::optional< T > getEntry(std::string key) const
Get a value of type T from the data map.
Definition DataComponent.h:31