#ifndef __scripting_system_hpp__ #define __scripting_system_hpp__ #include #include #include #include #include #include #include "boxed_value.hpp" #include "proxy_functions.hpp" #include "proxy_constructors.hpp" class Scripting_System { public: template void register_function(const Function &func, const std::string &name) { m_functions.insert(std::make_pair(name, boost::shared_ptr(new Proxy_Function_Impl(func)))); } template void add_object(const std::string &name, const Class &obj) { m_objects.insert(std::make_pair(name, Boxed_Value(obj))); } Boxed_Value get_object(const std::string &name) const { std::map::const_iterator itr = m_objects.find(name); if (itr != m_objects.end()) { return itr->second; } else { throw std::range_error("Object not known: " + name); } } template void register_type(const std::string &name) { m_types.insert(std::make_pair(name, &typeid(Type))); } boost::shared_ptr get_function(const std::string &t_name) { std::map >::const_iterator itr = m_functions.find(t_name); if (itr != m_functions.end()) { return itr->second; } else { throw std::range_error("Function not known: " + t_name); } } private: std::map m_objects; std::map m_types; std::map > m_functions; }; #endif