]> git.tdb.fi Git - libs/gltk.git/blob - source/logic.h
Rework how widget ownership works in Container
[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/objectloader.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::ObjectLoader<Logic>
25         {
26         private:
27                 const std::map<std::string, Widget *> &widgets;
28
29         public:
30                 Loader(Logic &, const std::map<std::string, Widget *> &);
31         private:
32                 void bind(const std::string &, const std::string &);
33         };
34
35         struct WidgetBinding
36         {
37                 Widget *wdg;
38                 std::string type;
39                 std::string data;
40         };
41
42 private:
43         std::list<WidgetBinding> bindings;
44
45 public:
46         const std::list<WidgetBinding> &get_bindings() const { return bindings; }
47 };
48
49 } // namespace GLtk
50 } // namespace Msp
51
52 #endif