-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2008 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#ifndef MSP_GLTK_USERINTERFACE_H_
#define MSP_GLTK_USERINTERFACE_H_
+#include <msp/core/maputils.h>
#include "logic.h"
#include "root.h"
void root();
};
+ typedef std::map<std::string, Widget *> WidgetMap;
+
private:
- std::map<std::string, Widget *> widgets;
+ WidgetMap widgets;
Root root;
Logic logic;
template<typename W>
W &get_widget(const std::string &n) const
{
- std::map<std::string, Widget *>::const_iterator i=widgets.find(n);
- if(i==widgets.end())
- throw KeyError("Unknown widget", n);
-
- W *w=dynamic_cast<W *>(i->second);
- if(!w)
- throw Exception("Widget type mismatch");
-
- return *w;
+ return dynamic_cast<W &>(*get_item(widgets, n));
}
template<typename W>
void get_widget(const std::string &n, W *&w) const
{
- w=&get_widget<W>(n);
+ w = &get_widget<W>(n);
}
};