ConfigManager.hpp

The ConfigManager templated class handles the building and configuration of new objects of the target type.

The manager is created with two keywords; one for the type of the managed class, and the other for the keyword to trigger commands for it.

For example, if we’re configuring an instruction set, the type might be ‘inst_set’ and the keyword might be ‘inst’. Then the configuration file can have lines like:

new inst_lib 4stack inst nopA inst inc inst divide cycle_cost=10 …

class ConfigManager_Base
#include <ConfigManager.hpp>

Subclassed by ConfigManager< MANAGED_TYPE >

Public Functions

inline ConfigManager_Base(const std::string &_type, const std::string &_command)
inline virtual ~ConfigManager_Base()
inline const std::string &GetTypeKeyword() const
inline const std::string &GetCommandKeyword() const
virtual void NewObject(const std::string &obj_name) = 0
virtual void UseObject(const std::string &obj_name) = 0
virtual bool CommandCallback(const std::string &command) = 0

Protected Attributes

const std::string type_keyword
const std::string command_keyword
template<class MANAGED_TYPE>
class ConfigManager : public ConfigManager_Base
#include <ConfigManager.hpp>

Public Functions

inline ConfigManager(const std::string &_type, const std::string &_command, std::function<bool(MANAGED_TYPE&, std::string)> _fun)
inline ~ConfigManager()
inline bool HasObject(const std::string &obj_name)
inline virtual void NewObject(const std::string &obj_name)
inline virtual void UseObject(const std::string &obj_name)
inline virtual bool CommandCallback(const std::string &command)

Private Members

std::map<std::string, MANAGED_TYPE*> name_map
MANAGED_TYPE *cur_obj
std::function<bool(MANAGED_TYPE&, std::string)> callback_fun