X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fresource.hh;h=5f1a71ab41e366596ef890f26806fd9f4d097173;hp=29ae114f9d4daa4cc1b5e0cd14d900d7611963fa;hb=382626aad0a683ed8642a6a807eea743db45f7f8;hpb=51069fee9139ab8d14ecc80dffbe5deecb73d9e0 diff --git a/src/moof/resource.hh b/src/moof/resource.hh index 29ae114..5f1a71a 100644 --- a/src/moof/resource.hh +++ b/src/moof/resource.hh @@ -88,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); } /** @@ -101,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); } @@ -164,6 +169,8 @@ public: */ static int reload_as_needed(); + static void print_types(); + private: @@ -188,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)); } }; @@ -212,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_; } @@ -238,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_; @@ -274,6 +285,9 @@ public: resource_handle(resource_ptr ptr) : resource_(ptr) {} + explicit resource_handle(const std::string& path) : + resource_(resource::load(path)) {} + /** * Get whether or not the handle is dereferenceable to the type of this