summaryrefslogtreecommitdiff
path: root/src/core/resource/ResourceLocator.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-16 18:56:48 +0100
committerAndreas Stöckel <andreas@somweyr.de>2015-02-16 18:56:48 +0100
commitf6069914af0d47bfea343b0babb734c9fd6d432d (patch)
treec5af9664dddcbe0a18b2edbf9074325b6af4a2af /src/core/resource/ResourceLocator.hpp
parentf69518b192ba5015e7ececddbfcf3a3695487d00 (diff)
Added "autocomplete" function to ResourceLocator and Registry
Diffstat (limited to 'src/core/resource/ResourceLocator.hpp')
-rw-r--r--src/core/resource/ResourceLocator.hpp58
1 files changed, 55 insertions, 3 deletions
diff --git a/src/core/resource/ResourceLocator.hpp b/src/core/resource/ResourceLocator.hpp
index c1d0807..d6a2ffc 100644
--- a/src/core/resource/ResourceLocator.hpp
+++ b/src/core/resource/ResourceLocator.hpp
@@ -21,6 +21,7 @@
#include <istream>
#include <memory>
+#include <vector>
#include "Resource.hpp"
@@ -60,6 +61,23 @@ protected:
const std::string &relativeTo) const = 0;
/**
+ * Tries to autocomplete the given filename by searching for files with this
+ * basename but different extensions. Returns a list of possible extended
+ * paths. May return an empty list if this function is not supported.
+ *
+ * @param path is the given filename for which versions with extension
+ * should be searched.
+ * @param type is the resource type, determining the search paths in which
+ * the resource is looked up.
+ * @param relativeTo is an already resolved Resource relative to which the
+ * file should be searched.
+ * @return a list of matching, autocompleted file paths.
+ */
+ virtual std::vector<std::string> doAutocomplete(
+ const std::string &path, const ResourceType type,
+ const std::string &relativeTo) const;
+
+ /**
* This method returns a stream containing the data of the resource at the
* given location.
*
@@ -80,6 +98,41 @@ public:
virtual ~ResourceLocator() {}
/**
+ * Tries to autocomplete the given filename by searching for files with this
+ * basename but different extensions. Returns a list of possible extended
+ * paths. May return an empty list if this function is not supported.
+ *
+ * @param path is the given filename for which versions with extension
+ * should be searched.
+ * @param type is the resource type, determining the search paths in which
+ * the resource is looked up.
+ * @param relativeTo is an already resolved Resource relative to which the
+ * file should be searched.
+ * @return a list of matching, autocompleted file paths.
+ */
+ std::vector<std::string> autocomplete(
+ const std::string &path,
+ const ResourceType type = ResourceType::UNKNOWN,
+ const Resource &relativeTo = NullResource) const;
+
+ /**
+ * Tries to autocomplete the given filename by searching for files with this
+ * basename but different extensions. Returns a list of possible extended
+ * paths. May return an empty list if this function is not supported.
+ *
+ * @param path is the given filename for which versions with extension
+ * should be searched.
+ * @param type is the resource type, determining the search paths in which
+ * the resource is looked up.
+ * @param relativeTo is the location of an already resolved resource
+ * relative to which this resource should be located.
+ * @return a list of matching, autocompleted file paths.
+ */
+ std::vector<std::string> autocomplete(const std::string &path,
+ const ResourceType type,
+ const std::string &relativeTo) const;
+
+ /**
* The locate function uses this ResourceLocator to search for a given
* Resource name (path parameter).
*
@@ -109,8 +162,7 @@ public:
* @return true if a resource could be found, false otherwise.
*/
bool locate(Resource &resource, const std::string &path,
- const ResourceType type,
- const std::string &relativeTo) const;
+ const ResourceType type, const std::string &relativeTo) const;
/**
* This method returns a stream containing the data of the resource at the
@@ -123,7 +175,7 @@ public:
* C++11 compiler does not yet support move semantics for
* streams.
*/
- std::unique_ptr<std::istream> stream(const std::string &location) const;
+ std::unique_ptr<std::istream> stream(const std::string &location) const;
};
/**