/*] Copyright (c) 2009-2010, 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. * **************************************************************************/ #ifndef _MOOF_RESOURCE_HH_ #define _MOOF_RESOURCE_HH_ /** * \file resource.hh * Interface for textures, sounds, and other types of resources. */ #include #include #include namespace moof { /** * Generic resource class. */ class resource { public: virtual ~resource() {} /** * Add a directory to search when looking for resource files. * \param paths A colon-separated list of directory paths. */ 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& pathList); /** * Get the path to a resource of a given name. * \param path The name of the resource to find. Upon successful * return, this is changed to an absolute path to the resource. * \param prefix A colon-separated list of subdirectories to search. * \param extension A colon-separated list of possible extensions. * \return True if a path to a resource was found, false otherwise. */ static bool find_path(std::string& path, const std::string& prefix = "", const std::string& extension = ""); /** * Get the path to a resource of a given name and open it if a resource * was found. * \param path The name of the resource to find. Upon successful * return, this is changed to an absolute path to the resource. * \param prefix A colon-separated list of subdirectories to search. * \param extension A colon-separated list of possible extensions. * \param mode The open mode. * \return The FILE* if the resource was found, 0 otherwise. */ static FILE* open_file(std::string& path, const std::string& prefix = "", const std::string& extension = "", const std::string& mode = "rb"); private: static std::vector search_paths_; }; } // namespace moof #endif // _MOOF_RESOURCE_HH_