Skip to content
Snippets Groups Projects
Commit fe67711a authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Fix constness of ObjectFinder, add flag to disable checking of files

parent 8a8c0f4a
No related branches found
No related tags found
1 merge request!71Object pose observer
......@@ -17,7 +17,7 @@ namespace armarx
Logging::setTag("ObjectFinder");
}
void ObjectFinder::init()
void ObjectFinder::init() const
{
if (packageDataDir.empty())
{
......@@ -36,7 +36,7 @@ namespace armarx
}
std::optional<ObjectInfo> ObjectFinder::findObject(const std::string& project, const std::string& name)
std::optional<ObjectInfo> ObjectFinder::findObject(const std::string& project, const std::string& name) const
{
init();
if (!project.empty())
......@@ -65,7 +65,7 @@ namespace armarx
return std::nullopt;
}
std::optional<ObjectInfo> ObjectFinder::findObject(const std::string& nameOrID)
std::optional<ObjectInfo> ObjectFinder::findObject(const std::string& nameOrID) const
{
init();
if (nameOrID.find("/") != nameOrID.npos)
......@@ -81,7 +81,7 @@ namespace armarx
}
}
std::vector<std::string> ObjectFinder::getProjects()
std::vector<std::string> ObjectFinder::getProjects() const
{
init();
const bool local = true;
......@@ -89,14 +89,14 @@ namespace armarx
return std::vector<std::string>(paths.begin(), paths.end());
}
std::vector<ObjectFinder::path> ObjectFinder::getProjectDirectories()
std::vector<ObjectFinder::path> ObjectFinder::getProjectDirectories() const
{
init();
const bool local = false;
return simox::fs::list_directory(_rootDirAbs(), local);
}
std::vector<ObjectInfo> ObjectFinder::findAllObjects()
std::vector<ObjectInfo> ObjectFinder::findAllObjects(bool checkPaths) const
{
init();
const bool local = true;
......@@ -105,14 +105,14 @@ namespace armarx
{
if (fs::is_directory(_rootDirAbs() / projectDir))
{
std::vector<ObjectInfo> project = findAllObjectsOfProject(projectDir);
std::vector<ObjectInfo> project = findAllObjectsOfProject(projectDir, checkPaths);
objects.insert(objects.end(), project.begin(), project.end());
}
}
return objects;
}
std::vector<ObjectInfo> ObjectFinder::findAllObjectsOfProject(const std::string& project)
std::vector<ObjectInfo> ObjectFinder::findAllObjectsOfProject(const std::string& project, bool checkPaths) const
{
init();
path projectDir = _rootDirAbs() / project;
......@@ -130,7 +130,7 @@ namespace armarx
if (fs::is_directory(projectDir / dir))
{
ObjectInfo object(packageName, packageDataDir, project, dir.filename());
if (object.checkPaths())
if (!checkPaths || object.checkPaths())
{
objects.push_back(object);
}
......
......@@ -20,20 +20,20 @@ namespace armarx
ObjectFinder(const std::string& objectsPackageName = "ArmarXObjects");
std::optional<ObjectInfo> findObject(const std::string& project, const std::string& name);
std::optional<ObjectInfo> findObject(const std::string& nameOrID);
std::optional<ObjectInfo> findObject(const std::string& project, const std::string& name) const;
std::optional<ObjectInfo> findObject(const std::string& nameOrID) const;
std::vector<std::string> getProjects();
std::vector<path> getProjectDirectories();
std::vector<std::string> getProjects() const;
std::vector<path> getProjectDirectories() const;
std::vector<ObjectInfo> findAllObjects();
std::vector<ObjectInfo> findAllObjectsOfProject(const std::string& project);
std::vector<ObjectInfo> findAllObjects(bool checkPaths = true) const;
std::vector<ObjectInfo> findAllObjectsOfProject(const std::string& project, bool checkPaths = true) const;
private:
void init();
void init() const;
path _rootDirAbs() const;
path _rootDirRel() const;
......@@ -42,10 +42,10 @@ namespace armarx
/// Name of package containing the object models (ArmarXObjects by default).
std::string packageName;
mutable std::string packageName;
/// Absolute path to data directory (e.g. "/.../repos/ArmarXObjects/data").
path packageDataDir;
mutable path packageDataDir;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment