1 #ifndef MSP_GL_RESOURCEMANAGER_H_
2 #define MSP_GL_RESOURCEMANAGER_H_
4 #include <msp/core/mutex.h>
5 #include <msp/core/semaphore.h>
6 #include <msp/core/thread.h>
7 #include <msp/datafile/collection.h>
24 struct ManagedResource
27 DataFile::Collection *collection;
30 Resource::AsyncLoader *loader;
32 ManagedResource(Resource &);
35 class LoadingThread: public Thread
48 ResourceManager &manager;
50 ManagedResource *volatile resource;
54 LoadingThread(ResourceManager &);
60 void set_resource(ManagedResource *);
61 ManagedResource *get_resource() const { return resource; }
63 State get_state() const { return state; }
68 typedef std::map<const Resource *, ManagedResource> ResourceMap;
69 typedef std::list<ManagedResource *> LoadQueue;
73 ResourceMap resources;
81 void set_loading_policy(LoadingPolicy);
82 void set_async_loads(bool);
84 void add_resource(Resource &);
85 void set_resource_location(Resource &, DataFile::Collection &, const std::string &);
86 void load_resource(const Resource &);
87 void remove_resource(Resource &);