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

Add timestamp query

parent 2c188fe3
No related branches found
No related tags found
1 merge request!95Add introspection in RemoteGui
......@@ -30,6 +30,12 @@ module armarx
long minTimestamp = -1; // -1 for oldest
long maxTimestamp = -1; // -1 for latest
};
/// Get just the timestamps without data. Default values for all.
class Timestamps extends EntityQuery
{
long minTimestamp = -1; // -1 for oldest
long maxTimestamp = -1; // -1 for latest
};
}
......
......@@ -71,11 +71,11 @@ namespace armarx::armem
{
Time min = fromIce<Time>(query.minTimestamp);
Time max = fromIce<Time>(query.maxTimestamp);
process(result, min, max, entity);
process(result, min, max, entity, false);
}
}
void EntityQueryProcessor::process(Entity& result, const Time& min, const Time& max, const Entity& entity) const
void EntityQueryProcessor::process(Entity& result, const Time& min, const Time& max, const Entity& entity, bool timestampsOnly) const
{
// Returns an iterator pointing to the first element that is not less than (i.e. greater or equal to) key.
auto begin = min.toMicroSeconds() > 0 ? entity.history.lower_bound(min) : entity.history.begin();
......@@ -84,7 +84,24 @@ namespace armarx::armem
for (auto it = begin; it != end && it != entity.history.end(); ++it)
{
result.addSnapshot(*it->second);
if (timestampsOnly)
{
result.history.emplace(it->second->time, nullptr);
}
else
{
result.addSnapshot(*it->second);
}
}
}
void EntityQueryProcessor::process(Entity& result, const query::entity::Timestamps& query, const Entity& entity) const
{
if (query.minTimestamp <= query.maxTimestamp || query.minTimestamp < 0 || query.maxTimestamp < 0)
{
Time min = fromIce<Time>(query.minTimestamp);
Time max = fromIce<Time>(query.maxTimestamp);
process(result, min, max, entity, true);
}
}
......
......@@ -25,8 +25,10 @@ namespace armarx::armem
void process(Entity& result, const query::entity::All& query, const Entity& entity) const;
void process(Entity& result, const query::entity::Single& query, const Entity& entity) const;
void process(Entity& result, const query::entity::Range& query, const Entity& entity) const;
void process(Entity& result, const query::entity::Timestamps& query, const Entity& entity) const;
void process(Entity& result, const Time& min, const Time& max, const Entity& entity) const;
void process(Entity& result, const Time& min, const Time& max, const Entity& entity,
bool timestampsOnly = false) const;
data::EntityPtr processToIce(const query::EntityQuery& query, const Entity& entity) const;
......
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