]> git.tdb.fi Git - libs/gltk.git/blob - source/resources.h
Change mspparser -> mspdatafile
[libs/gltk.git] / source / resources.h
1 #ifndef MSP_GLTK_RESOURCES_H_
2 #define MSP_GLTK_RESOURCES_H_
3
4 #include <msp/gl/font.h>
5 #include <msp/gl/texture.h>
6 #include <msp/datafile/loader.h>
7 #include "graphic.h"
8 #include "style.h"
9
10 namespace Msp {
11 namespace GLtk {
12
13 class Resources
14 {
15 public:
16
17         class Loader: public Msp::DataFile::Loader
18         {
19         public:
20                 Loader(Resources &);
21         private:
22                 Resources &res;
23
24                 void font(const std::string &);
25                 void texture(const std::string &);
26                 void graphic(const std::string &);
27                 void style(const std::string &, const std::string &);
28         };
29
30         Resources();
31         ~Resources();
32         const GL::Font &get_font(const std::string &) const;
33         const GL::Font &get_default_font() const;
34         const GL::Texture2D &get_texture(const std::string &) const;
35         const Graphic &get_graphic(const std::string &) const;
36         const Style &get_style(const std::string &, const std::string &) const;
37 private:
38         struct StyleId
39         {
40                 std::string widget;
41                 std::string name;
42
43                 StyleId(const std::string &w, const std::string &n): widget(w), name(n) { }
44                 bool operator<(const StyleId &) const;
45         };
46
47         typedef std::map<std::string, GL::Font *> FontMap;
48         typedef std::map<std::string, GL::Texture2D *> TextureMap;
49         typedef std::map<std::string, Graphic> GraphicMap;
50         typedef std::map<StyleId, Style> StyleMap;
51
52         FontMap fonts;
53         GL::Font *default_font;
54         TextureMap textures;
55         GraphicMap graphics;
56         StyleMap styles;
57
58         Resources(const Resources &);
59         Resources &operator=(const Resources &);
60 };
61
62 } // namespace GLtk
63 } // namespace Msp
64
65 #endif