]> git.tdb.fi Git - libs/gltk.git/blob - source/logic.h
689b39b41ec0b6f8f9c6504e982230ba1c1cb042
[libs/gltk.git] / source / logic.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_LOGIC_H_
9 #define MSP_GLTK_LOGIC_H_
10
11 #include <list>
12 #include <map>
13 #include <string>
14 #include <sigc++/slot.h>
15 #include <msp/core/except.h>
16 #include <msp/datafile/loader.h>
17
18 namespace Msp {
19 namespace GLtk {
20
21 class Widget;
22
23 /**
24 Stores use interface logic.  This is stored as actions associated to widgets.
25 Each action has type and data.  See also class Connector.
26 */
27 class Logic
28 {
29 public:
30         class Loader: public DataFile::Loader
31         {
32         private:
33                 Logic &logic;
34                 const std::map<std::string, Widget *> &widgets;
35
36         public:
37                 Loader(Logic &, const std::map<std::string, Widget *> &);
38         private:
39                 void action(const std::string &, const std::string &);
40         };
41
42         struct WidgetAction
43         {
44                 Widget *wdg;
45                 std::string type;
46                 std::string data;
47         };
48
49 private:
50         std::list<WidgetAction> actions;
51
52 public:
53         const std::list<WidgetAction> &get_actions() const { return actions; }
54 };
55
56 } // namespace GLtk
57 } // namespace Msp
58
59 #endif