]> git.tdb.fi Git - libs/gltk.git/blob - source/logic.h
Rework exceptions and use maputils
[libs/gltk.git] / source / logic.h
1 #ifndef MSP_GLTK_LOGIC_H_
2 #define MSP_GLTK_LOGIC_H_
3
4 #include <list>
5 #include <map>
6 #include <string>
7 #include <sigc++/slot.h>
8 #include <msp/datafile/loader.h>
9
10 namespace Msp {
11 namespace GLtk {
12
13 class Widget;
14
15 /**
16 Stores use interface logic.  This is represented as widget bindings.  Each
17 binding has type and data.
18
19 See also class Connector.
20 */
21 class Logic
22 {
23 public:
24         class Loader: public DataFile::Loader
25         {
26         private:
27                 Logic &logic;
28                 const std::map<std::string, Widget *> &widgets;
29
30         public:
31                 Loader(Logic &, const std::map<std::string, Widget *> &);
32         private:
33                 void bind(const std::string &, const std::string &);
34         };
35
36         struct WidgetBinding
37         {
38                 Widget *wdg;
39                 std::string type;
40                 std::string data;
41         };
42
43 private:
44         std::list<WidgetBinding> bindings;
45
46 public:
47         const std::list<WidgetBinding> &get_bindings() const { return bindings; }
48 };
49
50 } // namespace GLtk
51 } // namespace Msp
52
53 #endif