ActionManager.hpp

ActionManager collects sets of Actions to be looked up or manipulated later.

Note

Status: Beta

class ActionManager
#include <ActionManager.hpp>

Public Functions

inline ActionManager()
ActionManager(ActionManager&&) = default
inline ActionManager(const ActionManager &in)
inline ~ActionManager()
inline int GetNextID() const

Get the ID to be used for the next new function.

inline size_t GetSize() const

How many actions are in this manager?

inline ActionBase &operator[](const std::string &name)

Look up an action with the specified name.

inline const ActionBase &operator[](const std::string &name) const

Look up an action with the specified name (const version)

template<typename RETURN, typename ...ARGS>
inline auto &Add(const std::function<RETURN(ARGS...)> &in_fun, const std::string &name)

Add a functon to this manager with a pre-specified name.

template<typename RETURN, typename ...ARGS>
inline auto &Add(const std::function<RETURN(ARGS...)> &in_fun)

Add a function to this manager with an auto-generated name.

inline auto &Add(const ActionBase &action)

Add an action to this manager.

inline void PrintNames(std::ostream &os = std::cout)

Print out the name of all actions maintained by this manager.

Private Members

std::unordered_map<std::string, ActionBase*> action_map

A set of all actions handled by manager.

int next_id = 1

Unique ID for next new function.

std::string prefix = "emp_action_"

Prefix for function names to keep unique.