VarMap.hpp

VarMaps track arbitrary data by name (slow) or id (faster).

Note

Status: ALPHA

class VarMap
#include <VarMap.hpp>

Public Functions

inline VarMap()
inline VarMap(const VarMap &_in)
VarMap(VarMap&&) = default
inline ~VarMap()
inline const std::string &GetName(size_t id) const
inline size_t GetID(const std::string &name) const
inline bool Has(const std::string &name) const
template<typename T>
inline size_t Add(const std::string &name, const T &value)
inline size_t AddString(const std::string &name, const std::string &value)
inline size_t AddInt(const std::string &name, int value)
inline size_t AddDouble(const std::string &name, double value)
inline size_t AddChar(const std::string &name, char value)
inline size_t AddBool(const std::string &name, bool value)
template<typename T>
inline T &Get(size_t id)
template<typename T>
inline T &Get(const std::string &name)
template<typename T>
inline const T &Get(size_t id) const
template<typename T>
inline const T &Get(const std::string &name) const
inline TypeID GetType(size_t id) const
inline TypeID GetType(std::string name) const
inline std::string &GetString(const std::string &name)
inline int &GetInt(const std::string &name)
inline double &GetDouble(const std::string &name)
inline char &GetChar(const std::string &name)
inline bool &GetBool(const std::string &name)
inline const std::string &GetString(const std::string &name) const
inline int GetInt(const std::string &name) const
inline double GetDouble(const std::string &name) const
inline char GetChar(const std::string &name) const
inline bool GetBool(const std::string &name) const
template<typename T>
inline void Set(size_t id, const T &value)

Set a variable that already exists by ID.

template<typename T>
inline void Set(const std::string &name, const T &value)

Set a variable that already exists by name.

Private Members

vector<Ptr<VarBase>> vars

Vector of all current variables.

unordered_map<std::string, size_t> id_map

Map of names to vector positions.

struct VarBase

Public Functions

inline VarBase(const std::string &in_name)
inline virtual ~VarBase()
virtual Ptr<VarBase> Clone() const = 0
virtual TypeID GetTypeID() const = 0
virtual std::string ToString() const = 0

Public Members

std::string name

Name of this variable.

template<typename T>
struct VarInfo : public VarMap::VarBase

Public Functions

inline VarInfo(const std::string &name, const T &in_value)
inline Ptr<VarBase> Clone() const override
inline TypeID GetTypeID() const override
inline std::string ToString() const override

Public Members

T value

Current value of this variable.