The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
manager.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Chris Beck <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * Manages a collection of lua kernels containing plugin modules running
17  * as coroutines, running in various engine contexts.
18  */
19 
20 #ifndef INCLUDED_PLUGINS_MANAGER_HPP_
21 #define INCLUDED_PLUGINS_MANAGER_HPP_
22 
23 #include "config.hpp"
24 #include "utils/make_enum.hpp"
25 
26 #include <boost/ptr_container/ptr_vector.hpp>
27 #include <boost/scoped_ptr.hpp>
28 #include <boost/shared_ptr.hpp>
29 #include <string>
30 
31 struct plugin;
32 
33 class plugins_context;
34 class lua_kernel_base;
36 
38 public:
41 
42  static plugins_manager * get(); //this class is a singleton
43  lua_kernel_base * get_kernel_base(); // just to mess around with lua console and debug stuff
44 
45  void play_slice(const plugins_context &);
46  void notify_event(const std::string & name, const config & data);
47 
48  MAKE_ENUM( STATUS,
49  (NONE, "not created")
50  (RUNNING, "running")
51  (STOPPED, "stopped")
52  )
53 
54  size_t size();
55 
56  STATUS get_status(size_t idx);
57  std::string get_detailed_status(size_t idx);
58  std::string get_name (size_t idx);
59 
60  bool any_running();
61 
62  size_t load_plugin(const std::string & name, const std::string & filename); //throws exceptions in case of failure
63  size_t add_plugin(const std::string & name, const std::string & prog); //throws exceptions in case of failure
64 
65  void start_plugin(size_t idx); //throws exceptions in case of failure
66 
67  struct event {
70  };
71 
72 private:
73  boost::ptr_vector<plugin> plugins_;
75  boost::scoped_ptr<application_lua_kernel> kernel_;
76 };
77 
78 #endif
size_t add_plugin(const std::string &name, const std::string &prog)
Definition: manager.cpp:121
MAKE_ENUM(STATUS,(NONE,"not created")(RUNNING,"running")(STOPPED,"stopped")) size_t size()
STATUS get_status(size_t idx)
Definition: manager.cpp:75
size_t load_plugin(const std::string &name, const std::string &filename)
Definition: manager.cpp:134
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
Definitions for the interface to Wesnoth Markup Language (WML).
boost::scoped_ptr< application_lua_kernel > kernel_
Definition: manager.hpp:75
boost::shared_ptr< bool > playing_
Definition: manager.hpp:74
boost::ptr_vector< plugin > plugins_
Definition: manager.hpp:73
std::string get_detailed_status(size_t idx)
Definition: manager.cpp:86
std::string name
Definition: manager.hpp:68
void play_slice(const plugins_context &)
Definition: manager.cpp:161
std::string get_name(size_t idx)
Definition: manager.cpp:97
GLuint const GLchar * name
Definition: glew.h:1782
GLsizeiptr size
Definition: glew.h:1649
bool any_running()
Definition: manager.cpp:209
void start_plugin(size_t idx)
Definition: manager.cpp:104
lua_kernel_base * get_kernel_base()
Definition: manager.cpp:66
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
void notify_event(const std::string &name, const config &data)
Definition: manager.cpp:147
Defines the MAKE_ENUM macro.
GLsizei const GLcharARB ** string
Definition: glew.h:4503
plugins_manager(application_lua_kernel *)
Definition: manager.cpp:47