]> Dogcows Code - chaz/yoink/blobdiff - src/moof/resource.cc
remove some unused stlplus modules
[chaz/yoink] / src / moof / resource.cc
index 95b4c698501a05686a02d1789a3f428298939cb1..7a60d0e304e6e4c444dbeb5d920c3a5215c4e478 100644 (file)
@@ -1,15 +1,15 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
+#if HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <queue>
 
 #include "hash.hh"
 #include "resource.hh"
 
-
 #ifndef BUF_SIZE
-#define BUF_SIZE 4096
+#define BUF_SIZE 8192
 #endif
 
 
 namespace moof {
-       
+
 
 /*] Filesystem searching
  *************************************************************************/
@@ -44,7 +43,6 @@ void resource::set_search_paths(const std::string& paths)
        boost::split(search_paths_, paths, boost::is_any_of(":"));
 }
 
-
 std::string resource::find_file(const std::string& name)
 {
        std::string ext = stlplus::extension_part(name);
@@ -76,8 +74,8 @@ std::string resource::find_file(const std::string& name)
        return std::string();
 }
 
-std::string resource::find_file(const std::string& name,
-                                                               const std::string& ext)
+std::string
+resource::find_file(const std::string& name, const std::string& ext)
 {
        std::string actual_ext = stlplus::extension_part(name);
        if (actual_ext != ext)
@@ -105,9 +103,7 @@ static struct rsrc_list
        {
                hash<std::string,resource_weakptr,hash_function>::iterator it;
                for (it = table.begin(); it != table.end(); ++it)
-               {
                        log_warning("leaked resource:", (*it).first);
-               }
        }
 #endif
 } rsrc_list;
@@ -131,7 +127,7 @@ static struct watch_list
        int add(resource_ptr rsrc)
        {
                int wd = inotify_add_watch(fd, rsrc->path().c_str(),
-                                                                  IN_DELETE_SELF | IN_MODIFY);
+                               IN_DELETE_SELF | IN_MODIFY);
                table[wd] = rsrc;
                return wd;
        }
@@ -142,22 +138,19 @@ static struct watch_list
 } watch_list;
 #endif
 
-
 resource_ptr resource::load(const std::string& name)
 {
        std::string ext = stlplus::extension_part(name);
        return load_with_path(find_file(name, ext), ext);
 }
 
-resource_ptr resource::load(const std::string& name,
-                                                       const std::string& ext)
+resource_ptr resource::load(const std::string& name, const std::string& ext)
 {
        return load_with_path(find_file(name, ext), ext);
 }
 
-
-resource_ptr resource::load_with_path(const std::string& path,
-                                                                         const std::string& ext)
+resource_ptr
+resource::load_with_path(const std::string& path, const std::string& ext)
 {
        if (path.empty()) return resource_ptr();
 
@@ -189,7 +182,6 @@ resource_ptr resource::load_with_path(const std::string& path,
        return resource_ptr();
 }
 
-
 /*] Hotloading
  *************************************************************************/
 
@@ -237,7 +229,6 @@ int resource::reload_as_needed()
                }
        }
 #endif
-
        return count;
 }
 
@@ -260,32 +251,30 @@ resource::~resource()
 #endif
 }
 
-
 /*] Resource registration
  *************************************************************************/
 
 bool resource::call_registry(const std::string& ext,
-                                                        loader_ptr& loader,
-                                                        registry_action action)
+               loader_ptr& loader, registry_action action)
 {
        static std::map<std::string,loader_ptr> table;
 
        switch (action)
        {
-               case set:
-               {
-                       if (loader) table[ext] = loader;
-                       else        table.erase(ext);
-                       break;
-               }
+       case lookup:
+       {
+               std::map<std::string,loader_ptr>::iterator it;
+               it = table.find(ext);
+               if (it != table.end()) loader = (*it).second;
+               break;
+       }
 
-               case lookup:
-               {
-                       std::map<std::string,loader_ptr>::iterator it;
-                       it = table.find(ext);
-                       if (it != table.end()) loader = (*it).second;
-                       break;
-               }
+       case set:
+               if (loader)
+                       table[ext] = loader;
+               else
+                       table.erase(ext);
+               break;
        }
 
        return loader;
This page took 0.01962 seconds and 4 git commands to generate.