X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fresourcemanager.h;h=afa2c2d073e45b32b25332a91a3be9c7c8568461;hp=a1ff7aee2fc32adda60d12b0a63166c635e81822;hb=cfd4d36c2b6b6095ada3aef8082e5d409a233a21;hpb=d184ad8a88156a5b0cfe926e5aa66fd574556560 diff --git a/source/resourcemanager.h b/source/resourcemanager.h index a1ff7aee..afa2c2d0 100644 --- a/source/resourcemanager.h +++ b/source/resourcemanager.h @@ -13,6 +13,15 @@ namespace GL { class ResourceWatcher; +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() { } +}; + + class ResourceManager { public: @@ -23,6 +32,15 @@ public: LOAD_MANUALLY }; + struct ResourceLocation + { + DataFile::Collection *collection; + std::string name; + + ResourceLocation(); + ResourceLocation(DataFile::Collection &, const std::string &); + }; + private: struct ManagedResource { @@ -32,12 +50,13 @@ private: LOAD_QUEUED, LOADING, LOAD_FINISHED, - LOADED + LOADED, + LOAD_ERROR }; Resource *resource; - DataFile::Collection *collection; - std::string name; + ResourceLocation location; + bool load_priority; IO::Seekable *io; Resource::AsyncLoader *loader; State state; @@ -68,6 +87,9 @@ private: LoadQueue sync_queue; unsigned capacity; unsigned size; + std::list error_queue; + Mutex data_size_mutex; + UInt64 loaded_data_size; volatile bool done; public: @@ -86,6 +108,7 @@ private: public: bool sync(); bool needs_work() const { return size