]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/mag/include/server/plugin
update
[l4.git] / l4 / pkg / mag / include / server / plugin
1 // vi:ft=cpp
2 /*
3  * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #pragma once
11
12 #include <l4/mag/server/object>
13 #include <l4/re/video/goos>
14
15 namespace Mag_server {
16
17 class User_state;
18 class Core_api;
19
20 class Input_source
21 {
22 private:
23   friend class Core_api;
24   Input_source *_next_active;
25
26 protected:
27   Core_api *_core;
28
29 public:
30   explicit Input_source(Core_api *core = 0) : _core(core) {}
31   virtual void poll_events() = 0;
32   Input_source *next() const { return _next_active; }
33 };
34
35 class Core_api
36 {
37 private:
38   Input_source *_input;
39   Registry *_reg;
40   User_state *_ust;
41   L4::Cap<void> _rcv_cap;
42   L4::Cap<L4Re::Video::Goos> _fb;
43
44   // not instanziatable
45   Core_api(Core_api const &);
46   void operator = (Core_api const &);
47
48 public:
49   Core_api(Registry *r, User_state *u, L4::Cap<void> rcvc,
50            L4::Cap<L4Re::Video::Goos> fb)
51   : _reg(r), _ust(u), _rcv_cap(rcvc), _fb(fb)
52   {}
53
54   Registry *registry() const { return _reg; }
55   User_state *user_state() const { return _ust; }
56   Input_source *input_sources() const { return _input; }
57   L4::Cap<L4Re::Video::Goos> backend_fb() const { return _fb; }
58   void add_input_source(Input_source *i)
59   {
60     i->_next_active = _input;
61     _input = i;
62   }
63
64   L4::Cap<void> rcv_cap() const { return _rcv_cap; }
65 };
66
67 class Plugin
68 {
69 private:
70   friend class Plugin_manager;
71
72   char const *const _name;
73   unsigned _flags;
74   Plugin *_next;
75
76   static Plugin *_first;
77
78   Plugin(Plugin const &);
79   void operator = (Plugin const &);
80
81 protected:
82   unsigned &get_flags() { return _flags; }
83   Plugin(char const *name) : _name(name), _flags(0), _next(_first)
84   { _first = this; }
85
86 public:
87   enum Flag
88   {
89     F_started = 1
90   };
91
92   virtual char const *type() const { return "generic"; }
93   char const *name() const { return _name; }
94
95   bool started() const { return _flags & F_started; }
96
97   virtual void start(Core_api *) = 0;
98   virtual void stop() {}
99   virtual ~Plugin() {}
100 };
101
102 }