27 #define DBG_PLG LOG_STREAM(debug, log_plugins)
28 #define LOG_PLG LOG_STREAM(info, log_plugins)
29 #define WRN_PLG LOG_STREAM(warn, log_plugins)
30 #define ERR_PLG LOG_STREAM(err, log_plugins)
37 std::unique_ptr<application_lua_kernel::thread>
thread;
38 std::vector<plugins_manager::event>
queue;
52 add_plugin(
"Null Plugin",
"return function() end");
75 return plugin_manager_status::type::not_created;
77 return plugins_[idx].thread->is_running() ? plugin_manager_status::type::running : plugin_manager_status::type::stopped;
80 throw std::runtime_error(
"index out of bounds");
88 return plugins_[idx].thread->status();
91 throw std::runtime_error(
"index out of bounds");
98 throw std::runtime_error(
"index out of bounds");
103 DBG_PLG <<
"start_plugin[" << idx <<
"]";
106 DBG_PLG <<
"creating thread[" << idx <<
"]";
109 DBG_PLG <<
"finished [" << idx <<
"], status = '" <<
plugins_[idx].thread->status() <<
"'";
111 DBG_PLG <<
"thread already exists, skipping";
115 throw std::runtime_error(
"index out of bounds");
150 for (std::size_t idx = 0; idx <
size(); ++idx)
166 playing_ = std::make_shared<bool> (
true);
167 std::shared_ptr<bool> local =
playing_;
169 for (std::size_t idx = 0; idx <
size(); ++idx)
171 DBG_PLG <<
"play_slice[" << idx <<
"] ...";
179 std::vector<event> input =
plugins_[idx].queue;
180 plugins_[idx].queue = std::vector<event>();
183 std::vector<std::function<bool(
void)>> requests =
184 plugins_[idx].thread->run_script(ctxt, input);
186 DBG_PLG <<
"thread returned " << requests.size() <<
" requests";
188 for (std::size_t j = 0; j < requests.size(); ++j) {
190 if (!requests[j]()) {
196 DBG_PLG <<
"play_slice[" << idx <<
"] finished.";
198 DBG_PLG <<
"thread ["<< idx <<
"] not created";
200 DBG_PLG <<
"thread ["<< idx <<
"] not running";
209 for (std::size_t
i = 0;
i <
size(); ++
i) {
210 if (plugin_manager_status::type::running ==
get_status(
i)) {
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)
std::unique_ptr< application_lua_kernel > kernel_
plugin_manager_status::type get_status(std::size_t idx)
std::string get_name(std::size_t idx)
static plugins_manager * get()
void start_plugin(std::size_t idx)
std::size_t load_plugin(const std::string &name, const std::string &filename)
std::string get_detailed_status(std::size_t idx)
std::shared_ptr< bool > playing_
void play_slice(const plugins_context &)
lua_kernel_base * get_kernel_base()
std::vector< plugin > plugins_
plugins_manager(application_lua_kernel *)
std::size_t add_plugin(const std::string &name, const std::string &prog)
Standard logging facilities (interface).
static plugins_manager * singleton
static lg::log_domain log_plugins("plugins")
std::string filename
Filename.
std::vector< plugins_manager::event > queue
std::unique_ptr< application_lua_kernel::thread > thread