X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresourcemanager.h;h=399d479abd2111dab7de39b557846d03aa797b2c;hb=574abfb;hp=a1ff7aee2fc32adda60d12b0a63166c635e81822;hpb=d184ad8a88156a5b0cfe926e5aa66fd574556560;p=libs%2Fgl.git diff --git a/source/resourcemanager.h b/source/resourcemanager.h index a1ff7aee..399d479a 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,7 @@ private: LoadQueue sync_queue; unsigned capacity; unsigned size; + std::list error_queue; volatile bool done; public: @@ -116,7 +136,10 @@ public: void add_resource(Resource &); void *get_data_for_resource(const Resource &); void set_resource_location(Resource &, DataFile::Collection &, const std::string &); + void set_resource_location(Resource &, const ResourceLocation &); + const ResourceLocation *get_resource_location(const Resource &) const; void load_resource(Resource &); + bool is_resource_loaded(const Resource &) const; void resource_used(const Resource &); void remove_resource(Resource &);