From 47311cc8b211a7fef033d744d9eba9f308726ea8 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 20 Jan 2015 00:53:49 +0100 Subject: Refactored stuff surrounding the ResourceLocator class, implemented StaticResourceLocator which can be used for registering static resources (mainly for testing or if certain resources need to be available from the executable) --- src/plugins/boost/FileLocator.hpp | 50 +++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'src/plugins/boost/FileLocator.hpp') diff --git a/src/plugins/boost/FileLocator.hpp b/src/plugins/boost/FileLocator.hpp index 9cb705c..ffe5c8f 100644 --- a/src/plugins/boost/FileLocator.hpp +++ b/src/plugins/boost/FileLocator.hpp @@ -19,15 +19,13 @@ #ifndef _OUSIA_FILE_LOCATOR_HPP_ #define _OUSIA_FILE_LOCATOR_HPP_ -#include +#include +#include #include #include #include -#include - - namespace ousia { /** @@ -39,8 +37,25 @@ namespace ousia { * locations (e.g. online resources, .zip files, etc.). */ class FileLocator : public ResourceLocator { +public: + /** + * Type alias representing a Res + */ + using SearchPaths = std::map>; + private: - std::map> searchPaths; + /** + * Internal variable containing all stored search paths. + */ + SearchPaths searchPaths; + +protected: + bool doLocate(Resource &resource, const std::string &path, + const ResourceType type, + const std::string &relativeTo) const override; + + std::unique_ptr doStream( + const std::string &location) const override; public: FileLocator() : searchPaths() {} @@ -53,24 +68,23 @@ public: * resources of the specified types at the given path in the * future. */ - void addSearchPath(const boost::filesystem::path &path, - std::set types); + void addSearchPath(const std::string &path, std::set types); + + /** + * Adds a search path. Implicitly adds the search path for the "unknown" + * + * @param path is a fully qualified/canonical path to a directory. + * @param types is a set of Resource Types. The FileLocator will look for + * resources of the specified types at the given path in the + * future. + */ + void addSearchPath(const std::string &path); /** * Returns the backing map containing all search paths for a given type. * This is read-only. */ - const std::map> & - getSearchPaths() const - { - return searchPaths; - } - - Location locate(const std::string &path, const std::string &relativeTo, - const Type type) const override; - - std::unique_ptr stream( - const std::string &location) const override; + const SearchPaths &getSearchPaths() const { return searchPaths; } }; } -- cgit v1.2.3