]> Dogcows Code - chaz/yoink/blobdiff - src/moof/resource.hh
resource loading bugs and new sound class
[chaz/yoink] / src / moof / resource.hh
index 29ae114f9d4daa4cc1b5e0cd14d900d7611963fa..f8fd4f6327ee9b18ad47b6e0360e0c25115a5d1d 100644 (file)
@@ -88,9 +88,11 @@ public:
        template <class T>
        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<T>);
-               (*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<std::string,loader_ptr> type_lookup;
-       typedef boost::shared_ptr<type_lookup> type_lookup_ptr;
-       static type_lookup_ptr type_lookup_;
+       //typedef boost::shared_ptr<type_lookup> 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_;
This page took 0.019383 seconds and 4 git commands to generate.