X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fresource.hh;h=f8fd4f6327ee9b18ad47b6e0360e0c25115a5d1d;hp=a269a2d04d46b6b9aea405563a2be7a2e836a005;hb=1da520638918096276158ecdfaeebc14a3d70be7;hpb=bc795376d093ee097040f029b891b5435eb3bd21 diff --git a/src/moof/resource.hh b/src/moof/resource.hh index a269a2d..f8fd4f6 100644 --- a/src/moof/resource.hh +++ b/src/moof/resource.hh @@ -17,7 +17,7 @@ * Interface for textures, sounds, and other types of resources. */ -#include "../config.h" +#include "config.h" #include #include @@ -65,6 +65,8 @@ public: */ static bool find(const std::string& file); + static std::string find_file(const std::string& name); + /** * Get the path to a resource of a given name and open it if a resource * was found. @@ -86,9 +88,11 @@ public: template static void register_type(const std::string& extension) { - if (!type_lookup_) type_lookup_ = type_lookup_ptr(new type_lookup); + //if (!type_lookup_) type_lookup_ = type_lookup_ptr(new type_lookup); loader_ptr loader(new specific_loader); - (*type_lookup_)[extension] = loader; + //(*type_lookup_)[extension] = loader; + //type_lookup_[extension] = loader; + manage_loader(extension, loader, true); } /** @@ -99,7 +103,10 @@ public: */ static void unregister_type(const std::string& extension) { - type_lookup_->erase(extension); + //type_lookup_.erase(extension); + //type_lookup_->erase(extension); + loader_ptr loader; + manage_loader(extension, loader, true); } @@ -162,6 +169,8 @@ public: */ static int reload_as_needed(); + static void print_types(); + private: @@ -186,6 +195,7 @@ private: virtual resource* load(const std::string& path) { + log_info("loading resource of type ", typeid(T).name()); return new resource(new T(path)); } }; @@ -210,7 +220,7 @@ private: virtual ~specific_unloader() { - log_warning("unloading resource of type ", typeid(T).name()); + log_info("unloading resource of type ", typeid(T).name()); delete object_; } @@ -236,8 +246,11 @@ private: loader_ptr loader_; typedef std::map type_lookup; - typedef boost::shared_ptr type_lookup_ptr; - static type_lookup_ptr type_lookup_; + //typedef boost::shared_ptr type_lookup_ptr; + //static type_lookup_ptr type_lookup_; + //static type_lookup type_lookup_; + + static void manage_loader(const std::string& extension, loader_ptr& loader, bool set = false); #ifdef USE_HOTLOADING int wd_;