]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.h
Derive Resources from DataFile::Collection
[libs/gltk.git] / source / resources.h
index 40e44220a5b7de1b53011a14cb16d2ebe67ee6ee..cf8116dbc7392f1eb9a60d51df959c081040db48 100644 (file)
@@ -3,60 +3,39 @@
 
 #include <msp/gl/font.h>
 #include <msp/gl/texture.h>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/collection.h>
+#include <msp/path/path.h>
 #include "graphic.h"
 #include "style.h"
 
 namespace Msp {
 namespace GLtk {
 
-class Resources
+class Resources: public DataFile::Collection
 {
-public:
+private:
+       Path path;
+       GL::Font *default_font;
 
-       class Loader: public Msp::DataFile::Loader
+public:
+       class Loader: public Collection::Loader
        {
-       public:
-               Loader(Resources &);
        private:
                Resources &res;
 
+       public:
+               Loader(Resources &);
+       private:
                void font(const std::string &);
-               void texture(const std::string &);
-               void graphic(const std::string &);
-               void style(const std::string &, const std::string &);
        };
 
        Resources();
-       ~Resources();
-       const GL::Font &get_font(const std::string &) const;
+
+       void set_path(const Path &);
        const GL::Font &get_default_font() const;
-       const GL::Texture2D &get_texture(const std::string &) const;
-       const Graphic &get_graphic(const std::string &) const;
-       const Style &get_style(const std::string &, const std::string &) const;
 private:
-       struct StyleId
-       {
-               std::string widget;
-               std::string name;
-
-               StyleId(const std::string &w, const std::string &n): widget(w), name(n) { }
-               bool operator<(const StyleId &) const;
-       };
-
-       typedef std::map<std::string, GL::Font *> FontMap;
-       typedef std::map<std::string, GL::Texture2D *> TextureMap;
-       typedef std::map<std::string, Graphic> GraphicMap;
-       typedef std::map<StyleId, Style> StyleMap;
-
-       FontMap fonts;
-       GL::Font *default_font;
-       TextureMap textures;
-       GraphicMap graphics;
-       StyleMap styles;
-
-       Resources(const Resources &);
-       Resources &operator=(const Resources &);
+       GL::Font *create_font(const std::string &);
+       GL::Texture2D *create_texture(const std::string &);
 };
 
 } // namespace GLtk