10#include <VisionX/libraries/armem_human/aron/PersonInstance.aron.generated.h>
17 armarx::armem::client::query::Builder
28 if (not
query.providerName.empty())
51 if (not
query.providerName.empty())
63 std::vector<armarx::armem::human::Person>
69 std::vector<Person> humanProfiles;
78 entitySnapshot.forEachInstance(
79 [&humanProfiles, &
timestamp, &maxAge](
const auto& entityInstance)
84 timestamp - entityInstance.metadata().referencedTime;
95 humanProfiles.push_back(humanProfile);
100 return humanProfiles;
106 return "mem.human.profile.";
112 return {.memoryName =
"Human", .coreSegmentName =
"Profile"};
134 ARMARX_DEBUG <<
"[MappingDataReader] result: " << qResult;
139 return {.humanProfiles = {},
147 if (
query.providerName.empty())
151 std::vector<Person> allHumanProfiles;
153 coreSegment.forEachProviderSegment(
154 [
this, &allHumanProfiles, &
query](
const auto& providerSegment)
156 const std::vector<Person> humanProfiles =
158 std::copy(humanProfiles.begin(),
160 std::back_inserter(allHumanProfiles));
163 if (allHumanProfiles.empty())
166 return {.humanProfiles = {},
168 .errorMessage =
"No entities"};
177 if (not coreSegment.hasProviderSegment(
query.providerName))
180 <<
"` does not exist (yet).";
187 coreSegment.getProviderSegment(
query.providerName);
189 if (providerSegment.
empty())
192 return {.humanProfiles = {},
194 .errorMessage =
"No entities"};
201 const auto humanProfiles =
214 const std::string& lastName,
216 const std::string& providerName)
220 .providerName = providerName,
224 auto queryResult =
query(queryDefinition,
true);
226 std::vector<Preference> preferences;
230 for (
const auto& profile : queryResult.humanProfiles)
232 if (profile.id.firstName == firstName && profile.id.lastName == lastName)
235 return profile.preferences;
240 <<
"You tried to query a (Human) Profile, but the query was not successful "
241 <<
"because the person does not exist. Check first and last name.";
246 <<
"You tried to query a (Human) Profile, but the query was not successful";
254 const std::string& lastName,
255 const std::string& providerName)
259 .providerName = providerName,
263 auto queryResult =
query(queryDefinition,
true);
269 for (
const auto& profile : queryResult.humanProfiles)
271 if (profile.id.firstName == firstName && profile.id.lastName == lastName)
279 <<
"You tried to query a (Human) Profile, but the query was not successful "
280 <<
"because the person does not exist. Check first and last name.";
285 <<
"You tried to query a (Human) Profile, but the query was not successful";
292 std::vector<std::string>
294 const std::string& lastName,
295 const std::string& providerName)
299 if (!preferences.
drink.has_value())
303 return preferences.
drink->preferred;
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
static Duration Minutes(std::int64_t minutes)
Constructs a duration in minutes.
static Duration Hours(std::int64_t hours)
Constructs a duration in hours.
CoreSegmentT & getCoreSegment(const std::string &name)
bool forEachEntity(EntityFunctionT &&func)
QueryResult query(const QueryInput &input) const
Perform a query on the WM.
The query::Builder class provides a fluent-style specification of hierarchical queries.
QueryInput buildQueryInput() const
CoreSegmentSelector & coreSegments()
Start specifying core segments.
CoreSegmentSelector & withName(const std::string &name) override
ProviderSegmentSelector & providerSegments()
Start specifying provider segments.
EntitySelector & all() override
SnapshotSelector & snapshots()
Start specifying entity snapshots.
ProviderSegmentSelector & withName(const std::string &name) override
EntitySelector & entities()
Start specifying entities.
ProviderSegmentSelector & all() override
SnapshotSelector & beforeOrAtTime(Time timestamp)
SnapshotSelector & latest()
const armem::client::Reader & memoryReader() const
const Properties & properties() const
~ProfileReader() override
Properties defaultProperties() const override
std::vector< armarx::armem::human::Person > asPersonProfiles(const wm::ProviderSegment &providerSegment, const DateTime ×tamp, const Duration &maxAge) const
armarx::armem::human::Person queryLatestProfileByName(const std::string &firstName, const std::string &lastName, const std::string &providerName="All Profiles")
armarx::armem::human::Preferences queryPreferences(const std::string &firstName, const std::string &lastName, const Duration &maxAge, const std::string &providerName="All Profiles")
std::string propertyPrefix() const override
::armarx::armem::client::query::Builder buildQuery(const Query &query) const
Result query(const Query &query, bool latest) const
::armarx::armem::client::query::Builder buildLatestQuery(const Query &query) const
std::vector< std::string > getPreferredDrinks(const std::string &firstName, const std::string &lastName, const std::string &providerName="All Profiles")
Returns a list of a humans preferred drinks.
Represents a point in time.
bool isPositive() const
Tests whether the duration is positive (value in µs > 0).
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
void fromAron(const armarx::human::arondto::HumanPose &dto, HumanPose &bo)
armarx::core::time::Duration Duration
std::optional< AronClass > tryCast(const wm::EntityInstance &item)
Tries to cast a armem::EntityInstance to AronClass.
std::string GetHandledExceptionString()
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
wm::Memory memory
The slice of the memory that matched the query.
std::optional< Preference > drink