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

Add getFirstSnapshot()

parent 304c8b08
No related branches found
No related tags found
2 merge requests!188ArMem Updates,!185Clean up interfaces and unneeded code in memory core classes
...@@ -178,12 +178,25 @@ namespace armarx::armem::base ...@@ -178,12 +178,25 @@ namespace armarx::armem::base
{ {
return const_cast<EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getLatestSnapshot()); return const_cast<EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getLatestSnapshot());
} }
const EntitySnapshotT& getLatestSnapshot() const const EntitySnapshotT& getLatestSnapshot() const
{ {
return getLatestItem().second; return getLatestItem().second;
} }
/**
* @brief Return the snapshot with the most recent timestamp.
* @return The latest snapshot.
* @throw `armem::error::EntityHistoryEmpty` If the history is empty.
*/
EntitySnapshotT& getFirstSnapshot()
{
return const_cast<EntitySnapshotT&>(const_cast<const EntityBase*>(this)->getFirstSnapshot());
}
const EntitySnapshotT& getFirstSnapshot() const
{
return getFirstItem().second;
}
/** /**
* @brief Return the lastest snapshot before time. * @brief Return the lastest snapshot before time.
...@@ -541,6 +554,23 @@ namespace armarx::armem::base ...@@ -541,6 +554,23 @@ namespace armarx::armem::base
return *this->_container.rbegin(); return *this->_container.rbegin();
} }
/**
* @brief Return the snapshot with the least recent timestamp.
* @return The first snapshot.
* @throw `armem::error::EntityHistoryEmpty` If the history is empty.
*/
virtual
const typename ContainerT::value_type&
getFirstItem() const
{
if (this->_container.empty())
{
throw armem::error::EntityHistoryEmpty(name(), "when getting the first snapshot.");
}
return *this->_container.begin();
}
}; };
} }
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