* Interface for textures, sounds, and other types of resources.
*/
+#include "config.h"
+
#include <cstdio>
#include <map>
#include <stdexcept>
#include <moof/debug.hh>
-#if HAVE_CONFIG_H
-#include "../config.h"
-#endif
-
namespace moof {
*/
static void add_search_paths(const std::string& paths);
- /**
- * Add directories to search when looking for resource files.
- * \param pathList The list of directory paths.
- */
- static void add_search_paths(const std::vector<std::string>& pathList);
-
/**
* Get the path to a resource of a given name.
*/
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.
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);
}
/**
*/
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);
}
*/
static int reload_as_needed();
+ static void print_types();
+
private:
virtual resource* load(const std::string& path)
{
+ log_info("loading resource of type ", typeid(T).name());
return new resource(new T(path));
}
};
virtual ~specific_unloader()
{
- log_warning("unloading resource of type ", typeid(T).name());
+ log_info("unloading resource of type ", typeid(T).name());
delete object_;
}
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_;