summaryrefslogtreecommitdiff
path: root/src/core/Registry.cpp
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/Registry.cpp
parentf69518b192ba5015e7ececddbfcf3a3695487d00 (diff)
Added "autocomplete" function to ResourceLocator and Registry
Diffstat (limited to 'src/core/Registry.cpp')
-rw-r--r--src/core/Registry.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core/Registry.cpp b/src/core/Registry.cpp
index 2bb6a98..e950cdc 100644
--- a/src/core/Registry.cpp
+++ b/src/core/Registry.cpp
@@ -131,5 +131,30 @@ bool Registry::locateResource(Resource &resource, const std::string &path,
return false;
}
+
+std::vector<std::string> Registry::autocompleteResource(
+ const std::string &path, ResourceType type,
+ const Resource &relativeTo) const
+{
+ std::vector<std::string> res;
+
+ // Try the locator of the given "relativeTo" resource first
+ if (relativeTo.isValid()) {
+ res = relativeTo.getLocator().autocomplete(path, type, relativeTo);
+ if (!res.empty()) {
+ return res;
+ }
+ }
+
+ // Iterate over all registered locators and try to autocomplete the given
+ // path
+ for (auto &locator : locators) {
+ res = locator->autocomplete(path, type, relativeTo);
+ if (!res.empty()) {
+ return res;
+ }
+ }
+ return res;
+}
}