// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. #include #include #include #include using namespace gras; typedef std::map > CallableRegistry; Callable::Callable(void) { _call_registry.reset(new CallableRegistry()); } Callable::~Callable(void) { _call_registry.reset(); } void Callable::_register_call(const std::string &key, void *entry) { CallableRegistry *cr = reinterpret_cast(_call_registry.get()); (*cr)[key].reset(reinterpret_cast(entry)); } PMCC Callable::_handle_call(const std::string &key, const PMCC *args) { CallableRegistry *cr = reinterpret_cast(_call_registry.get()); boost::shared_ptr entry = (*cr)[key]; if (not entry) throw std::invalid_argument("Callable: no method registered for key: " + key); return entry->call(args); } CallableRegistryEntry::CallableRegistryEntry(void) { //NOP } CallableRegistryEntry::~CallableRegistryEntry(void) { //NOP }