Skip to content
Snippets Groups Projects
Commit a2dee547 authored by Fabian Reister's avatar Fabian Reister
Browse files

object class reader: +getAllObjectClasses

parent 57f30582
No related branches found
No related tags found
No related merge requests found
Pipeline #21592 failed
...@@ -36,10 +36,10 @@ namespace armarx::armem::obj::clazz ...@@ -36,10 +36,10 @@ namespace armarx::armem::obj::clazz
{ {
armem::client::query::Builder builder; armem::client::query::Builder builder;
auto& entities = builder.coreSegments() auto& entities = builder.coreSegments()
.withName(properties().coreSegmentName) .withName(properties().coreSegmentName)
.providerSegments() .providerSegments()
.all() .all()
.entities(); .entities();
for (const ObjectID& objectID : objectIDs) for (const ObjectID& objectID : objectIDs)
{ {
...@@ -67,6 +67,40 @@ namespace armarx::armem::obj::clazz ...@@ -67,6 +67,40 @@ namespace armarx::armem::obj::clazz
return objectClasses; return objectClasses;
} }
std::map<ObjectID, armem::clazz::ObjectClass>
ClassReader::getAllObjectClasses()
{
armem::client::query::Builder builder;
// clang-format off
builder
.coreSegments().withName(properties().coreSegmentName)
.providerSegments().all()
.entities().all()
.snapshots().latest();
// clang-format on
const armem::client::QueryResult result = memoryReader().query(builder);
if (not result.success)
{
throw armem::error::QueryFailed(result.errorMessage);
}
std::map<ObjectID, armem::clazz::ObjectClass> objectClasses;
result.memory.forEachInstance(
[&objectClasses](const armem::wm::EntityInstance& instance) -> bool
{
const ObjectID classID = ObjectID::FromString(instance.id().entityName);
auto aron = instance.dataAs<armarx::armem::arondto::ObjectClass>();
armarx::armem::clazz::fromAron(aron, objectClasses[classID]);
return true;
});
return objectClasses;
}
std::string std::string
ClassReader::propertyPrefix() const ClassReader::propertyPrefix() const
{ {
......
...@@ -46,6 +46,8 @@ namespace armarx::armem::obj::clazz ...@@ -46,6 +46,8 @@ namespace armarx::armem::obj::clazz
std::map<armarx::ObjectID, armem::clazz::ObjectClass> std::map<armarx::ObjectID, armem::clazz::ObjectClass>
getObjectClasses(const std::vector<armarx::ObjectID>& objectIDs); getObjectClasses(const std::vector<armarx::ObjectID>& objectIDs);
std::map<armarx::ObjectID, armem::clazz::ObjectClass> getAllObjectClasses();
protected: protected:
std::string propertyPrefix() const final; std::string propertyPrefix() const final;
Properties defaultProperties() const final; Properties defaultProperties() const final;
......
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