From 653cb96ef0b156331f6b2d9b599352935014273a Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Mon, 11 Sep 2023 08:55:38 +0200
Subject: [PATCH] Update example client

---
 .../ExampleMemoryClient.cpp                   | 28 +++++++++++++++----
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp b/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp
index e7fdc5eaa..7fea318b5 100644
--- a/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp
+++ b/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp
@@ -205,6 +205,8 @@ namespace armarx
         return armem::MemoryID(result.segmentID);
     }
 
+    // COMMIT
+
     armem::MemoryID
     ExampleMemoryClient::commitSingleSnapshot(const armem::MemoryID& entityID)
     {
@@ -272,10 +274,12 @@ namespace armarx
         }
     }
 
+    // QUERY
+
     void
     ExampleMemoryClient::queryLatestSnapshot(const armem::MemoryID& entityID)
     {
-        ARMARX_IMPORTANT << "Querying latest snapshot: "
+        ARMARX_IMPORTANT << "Querying latest snapshot in entity: "
                          << "\n- entityID:     \t'" << entityID << "'";
 
         armem::client::query::Builder builder;
@@ -295,6 +299,8 @@ namespace armarx
             ARMARX_IMPORTANT << "Getting entity via ID";
 
             armem::wm::Memory& memory = qResult.memory;
+            ARMARX_CHECK(memory.hasInstances());
+
             ARMARX_CHECK_GREATER_EQUAL(memory.size(), 1);
 
             const armem::wm::Entity* entity = memory.findEntity(entityID);
@@ -335,13 +341,23 @@ namespace armarx
         if (qResult.success)
         {
             armem::wm::Memory memory = std::move(qResult.memory);
-            const armem::wm::EntitySnapshot& entitySnapshot =
-                memory.getEntity(snapshotID).getLatestSnapshot();
+            {
+                const armem::wm::EntitySnapshot& entitySnapshot = memory.getLatestSnapshot();
 
-            ARMARX_INFO << "Result snapshot: "
-                        << "\n- time:        \t" << entitySnapshot.time() << "\n- # instances: \t"
-                        << entitySnapshot.size();
+                ARMARX_INFO << "Result snapshot: "
+                            << "\n- time:        \t" << entitySnapshot.time()
+                            << "\n- # instances: \t" << entitySnapshot.size();
+            }
+            {
+                const armem::wm::EntitySnapshot& entitySnapshot =
+                    memory.getEntity(snapshotID).getLatestSnapshot();
+
+                ARMARX_INFO << "Result snapshot: "
+                            << "\n- time:        \t" << entitySnapshot.time()
+                            << "\n- # instances: \t" << entitySnapshot.size();
+            }
         }
+
         else
         {
             ARMARX_ERROR << qResult.errorMessage;
-- 
GitLab