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

Add getLatestTimestamp()

parent a4917218
No related branches found
No related tags found
1 merge request!95Add introspection in RemoteGui
......@@ -88,14 +88,15 @@ namespace armarx::armem
const EntitySnapshot& Entity::getLatestSnapshot() const
{
if (history.empty())
{
throw armem::error::EntityHistoryEmpty(name, "when getting the latest snapshot.");
}
ARMARX_CHECK_NOT_NULL(history.rbegin()->second);
return *history.rbegin()->second;
auto& latest = getLatestItem();
ARMARX_CHECK_NOT_NULL(latest.second);
return *latest.second;
}
Time Entity::getLatestTimestamp() const
{
return getLatestItem().first;
}
std::vector<Time> Entity::getTimestamps() const
{
......@@ -168,4 +169,13 @@ namespace armarx::armem
}
}
const std::map<Time, EntitySnapshotPtr>::value_type& Entity::getLatestItem() const
{
if (history.empty())
{
throw armem::error::EntityHistoryEmpty(name, "when getting the latest snapshot.");
}
return *history.rbegin();
}
}
......@@ -42,10 +42,20 @@ namespace armarx::armem
/**
* @brief Return the snapshot with the most recent timestamp.
* @return The latest snapshot.
* @throw `armem::error::EntityHistoryEmpty` If the history is empty.
*/
EntitySnapshot& getLatestSnapshot();
const EntitySnapshot& getLatestSnapshot() const;
/**
* @brief Get the latest timestamp.
* @throw `armem::error::EntityHistoryEmpty` If the history is empty.
*/
Time getLatestTimestamp() const;
/**
* @brief Get all timestamps in the history.
*/
std::vector<Time> getTimestamps() const;
......@@ -81,6 +91,13 @@ namespace armarx::armem
void truncateHistoryToSize();
void checkEntityName(const std::string& name) const;
/**
* @brief Return the snapshot with the most recent timestamp.
* @return The latest snapshot.
* @throw `armem::error::EntityHistoryEmpty` If the history is empty.
*/
const std::map<Time, EntitySnapshotPtr>::value_type& getLatestItem() const;
public:
......
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