]> git.tdb.fi Git - libs/gltk.git/blob - source/logic.cpp
40d06b218b1aa4b01f9de19ac6df9189bad0d1bb
[libs/gltk.git] / source / logic.cpp
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 #include "logic.h"
9
10 using namespace std;
11
12 namespace Msp {
13 namespace GLtk {
14
15 Logic::Loader::Loader(Logic &l, const map<string, Widget *> &w):
16         logic(l),
17         widgets(w)
18 {
19         add("action", &Loader::action);
20 }
21
22 void Logic::Loader::action(const string &wdg, const string &data)
23 {
24         map<string, Widget *>::const_iterator i=widgets.find(wdg);
25         if(i==widgets.end())
26                 throw KeyError("Unknown widget", wdg);
27
28         unsigned colon=data.find(':');
29         WidgetAction act;
30         act.wdg=i->second;
31         act.type=data.substr(0, colon);
32         if(colon!=string::npos)
33                 act.data=data.substr(colon+1);
34         logic.actions.push_back(act);
35 }
36
37 } // namespace GLtk
38 } // namespace Msp