The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
manager.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2014 - 2025
3 by Chris Beck <render787@gmail.com>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16/**
17 * Manages a collection of lua kernels containing plugin modules running
18 * as coroutines, running in various engine contexts.
19 */
20
21#pragma once
22
23#include "config.hpp"
25
26#include <string>
27
28struct plugin;
29
30class plugins_context;
31class lua_kernel_base;
33
35public:
38
39 static plugins_manager * get(); //this class is a singleton
40 lua_kernel_base * get_kernel_base(); // just to mess around with lua console and debug stuff
41
42 void play_slice(const plugins_context &);
43 void notify_event(const std::string & name, const config & data);
44
45 std::size_t size();
46
47 plugin_manager_status::type get_status(std::size_t idx);
48 std::string get_detailed_status(std::size_t idx);
49 std::string get_name (std::size_t idx);
50
51 bool any_running();
52
53 std::size_t load_plugin(const std::string & name, const std::string & filename); //throws exceptions in case of failure
54 std::size_t add_plugin(const std::string & name, const std::string & prog); //throws exceptions in case of failure
55
56 void start_plugin(std::size_t idx); //throws exceptions in case of failure
57
58 struct event {
59 std::string name;
61 };
62
63private:
64 // TODO: this used to use boost::ptr_vector. Need to consider if there are some performance implications to not doing so
65 std::vector<plugin> plugins_;
66 std::shared_ptr<bool> playing_;
67 std::unique_ptr<application_lua_kernel> kernel_;
68};
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
std::size_t size()
Definition manager.cpp:68
void notify_event(const std::string &name, const config &data)
Definition manager.cpp:144
std::unique_ptr< application_lua_kernel > kernel_
Definition manager.hpp:67
plugin_manager_status::type get_status(std::size_t idx)
Definition manager.cpp:72
std::string get_name(std::size_t idx)
Definition manager.cpp:94
static plugins_manager * get()
Definition manager.cpp:58
void start_plugin(std::size_t idx)
Definition manager.cpp:101
bool any_running()
Definition manager.cpp:206
std::size_t load_plugin(const std::string &name, const std::string &filename)
Definition manager.cpp:131
std::string get_detailed_status(std::size_t idx)
Definition manager.cpp:83
std::shared_ptr< bool > playing_
Definition manager.hpp:66
void play_slice(const plugins_context &)
Definition manager.cpp:158
lua_kernel_base * get_kernel_base()
Definition manager.cpp:63
std::vector< plugin > plugins_
Definition manager.hpp:65
std::size_t add_plugin(const std::string &name, const std::string &prog)
Definition manager.cpp:118
Definitions for the interface to Wesnoth Markup Language (WML).
std::string_view data
Definition picture.cpp:188
std::string filename
Filename.