X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fresourcemanager.h;h=9dcd9b997a56a25214ea691d27f2f616197ae55f;hp=a2a4975db5185eaf3eadf7348e995f9a0b4ca5b7;hb=f141ae14619bfbd51a7e6871c55edbdd17ac3417;hpb=508319df28270eccdfa03a880a8604549278a139 diff --git a/source/resourcemanager.h b/source/resourcemanager.h index a2a4975d..9dcd9b99 100644 --- a/source/resourcemanager.h +++ b/source/resourcemanager.h @@ -11,11 +11,12 @@ namespace Msp { namespace GL { -class ResourceWatcher; +class ResourceObserver; class resource_load_error: public std::runtime_error { public: + resource_load_error(const std::string &, const std::string &); resource_load_error(const std::string &, const std::exception &); virtual ~resource_load_error() throw() { } }; @@ -31,6 +32,15 @@ public: LOAD_MANUALLY }; + struct ResourceLocation + { + DataFile::Collection *collection; + std::string name; + + ResourceLocation(); + ResourceLocation(DataFile::Collection &, const std::string &); + }; + private: struct ManagedResource { @@ -45,14 +55,14 @@ private: }; Resource *resource; - DataFile::Collection *collection; - std::string name; + ResourceLocation location; + bool load_priority; IO::Seekable *io; Resource::AsyncLoader *loader; State state; unsigned last_used; UInt64 data_size; - std::vector watchers; + std::vector observers; ManagedResource(Resource &); @@ -62,8 +72,8 @@ private: void finish_loading(); void unload(); - void add_watcher(ResourceWatcher &); - void remove_watcher(ResourceWatcher &); + void add_observer(ResourceObserver &); + void remove_observer(ResourceObserver &); }; typedef std::list LoadQueue; @@ -78,6 +88,8 @@ private: unsigned capacity; unsigned size; std::list error_queue; + Mutex data_size_mutex; + UInt64 loaded_data_size; volatile bool done; public: @@ -96,6 +108,7 @@ private: public: bool sync(); bool needs_work() const { return size