20 #include <boost/ptr_container/ptr_vector.hpp>
21 #include <boost/make_shared.hpp>
22 #include <boost/scoped_ptr.hpp>
23 #include <boost/shared_ptr.hpp>
31 #define DBG_PLG LOG_STREAM(debug, log_plugins)
32 #define LOG_PLG LOG_STREAM(info, log_plugins)
33 #define WRN_PLG LOG_STREAM(warn, log_plugins)
34 #define ERR_PLG LOG_STREAM(err, log_plugins)
41 boost::scoped_ptr<application_lua_kernel::thread>
thread;
42 std::vector<plugins_manager::event>
queue;
55 add_plugin(
"Null Plugin",
"return function() end");
80 return plugins_[idx].thread->is_running() ? plugins_manager::STATUS::RUNNING : plugins_manager::STATUS::STOPPED;
83 throw std::runtime_error(
"index out of bounds");
91 return plugins_[idx].thread->status();
94 throw std::runtime_error(
"index out of bounds");
101 throw std::runtime_error(
"index out of bounds");
106 DBG_PLG <<
"start_plugin[" << idx <<
"]\n";
109 DBG_PLG <<
"creating thread[" << idx <<
"]\n";
112 DBG_PLG <<
"finished [" << idx <<
"], status = '" <<
plugins_[idx].thread->status() <<
"'\n";
114 DBG_PLG <<
"thread already exists, skipping\n";
118 throw std::runtime_error(
"index out of bounds");
153 for (
size_t idx = 0; idx <
size(); ++idx)
169 playing_ = boost::make_shared<bool> (
true);
172 for (
size_t idx = 0; idx <
size(); ++idx)
174 DBG_PLG <<
"play_slice[" << idx <<
"] ... \n";
183 plugins_[idx].queue = std::vector<event>();
186 std::vector<std::function<bool(void)> > requests =
187 plugins_[idx].thread->run_script(ctxt, input);
189 DBG_PLG <<
"thread returned " << requests.size() <<
" requests\n";
191 for (
size_t j = 0; j < requests.size(); ++j) {
193 if (!requests[j]()) {
199 DBG_PLG <<
"play_slice[" << idx <<
"] finished.\n";
201 DBG_PLG <<
"thread ["<< idx <<
"] not created\n";
203 DBG_PLG <<
"thread ["<< idx <<
"] not running\n";
212 for (
size_t i = 0;
i <
size(); ++
i) {
size_t add_plugin(const std::string &name, const std::string &prog)
GLenum GLenum GLenum input
boost::scoped_ptr< application_lua_kernel::thread > thread
STATUS get_status(size_t idx)
size_t load_plugin(const std::string &name, const std::string &filename)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
boost::scoped_ptr< application_lua_kernel > kernel_
boost::shared_ptr< bool > playing_
boost::ptr_vector< plugin > plugins_
std::string get_detailed_status(size_t idx)
static plugins_manager * singleton
std::vector< plugins_manager::event > queue
void play_slice(const plugins_context &)
std::string get_name(size_t idx)
GLuint const GLchar * name
void start_plugin(size_t idx)
Standard logging facilities (interface).
lua_kernel_base * get_kernel_base()
A config object defines a single node in a WML file, with access to child nodes.
void notify_event(const std::string &name, const config &data)
static lg::log_domain log_plugins("plugins")
GLsizei const GLcharARB ** string
GLsizei GLsizei GLchar * source
static plugins_manager * get()
plugins_manager(application_lua_kernel *)