X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fresourcemanager.h;h=9dcd9b997a56a25214ea691d27f2f616197ae55f;hp=07b0aaf09f0574fe2ee8f6fbaea7be162f9660b7;hb=HEAD;hpb=8ed7051d1a80c7e8b198d96575338eee6a5e2485 diff --git a/source/resourcemanager.h b/source/resourcemanager.h deleted file mode 100644 index 07b0aaf0..00000000 --- a/source/resourcemanager.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef MSP_GL_RESOURCEMANAGER_H_ -#define MSP_GL_RESOURCEMANAGER_H_ - -#include -#include -#include -#include -#include "resource.h" - -namespace Msp { -namespace GL { - -class ResourceManager -{ -public: - enum LoadingPolicy - { - LOAD_IMMEDIATELY, - LOAD_ON_DEMAND, - LOAD_MANUALLY - }; - -private: - struct ManagedResource - { - Resource *resource; - DataFile::Collection *collection; - std::string name; - IO::Seekable *io; - Resource::AsyncLoader *loader; - bool loaded; - unsigned last_used; - - ManagedResource(Resource &); - - void start_loading(); - void finish_loading(); - void unload(); - }; - - class LoadingThread: public Thread - { - public: - enum State - { - IDLE, - SYNC_PENDING, - BUSY, - LOAD_FINISHED, - TERMINATING - }; - - private: - ResourceManager &manager; - Semaphore sem; - ManagedResource *volatile resource; - volatile State state; - - public: - LoadingThread(ResourceManager &); - - private: - virtual void main(); - - public: - void set_resource(ManagedResource *); - ManagedResource *get_resource() const { return resource; } - void sync(); - State get_state() const { return state; } - - void terminate(); - }; - - typedef std::map ResourceMap; - typedef std::list LoadQueue; - - LoadingPolicy policy; - bool async_loads; - ResourceMap resources; - LoadQueue queue; - unsigned frame; - unsigned min_retain_frames; - unsigned max_retain_frames; - unsigned next_unload; - LoadingThread thread; - -public: - ResourceManager(); - ~ResourceManager(); - - void set_loading_policy(LoadingPolicy); - void set_async_loads(bool); - void set_max_retain_frames(unsigned); - - void add_resource(Resource &); - void *get_data_for_resource(const Resource &); - void set_resource_location(Resource &, DataFile::Collection &, const std::string &); - void load_resource(Resource &); - void resource_used(const Resource &); - void remove_resource(Resource &); - - void tick(); -}; - -} // namespace GL -} // namespace Msp - -#endif