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

Fix names being empty when using move-add()

parent dc15830d
No related branches found
No related tags found
2 merge requests!192Fix bugs in ArMem and make disk loading and storing nicer,!188ArMem Updates
......@@ -284,7 +284,8 @@ namespace armarx::armem::base
/// Move and insert a provider segment.
ProviderSegmentT& addProviderSegment(ProviderSegmentT&& providerSegment)
{
return this->_derived().addProviderSegment(providerSegment.name(), std::move(providerSegment));
const std::string name = providerSegment.name(); // Copy before move.
return this->_derived().addProviderSegment(name, std::move(providerSegment));
}
/// Insert a provider segment in-place.
......
......@@ -529,26 +529,33 @@ namespace armarx::armem::base
});
}
/**
* @brief Add a single snapshot with data.
* @param snapshot The snapshot.
* @return The stored snapshot.
*/
/// Add a snapshot at the given time.
EntitySnapshotT& addSnapshot(const Time& timestamp)
{
return this->addSnapshot(timestamp, EntitySnapshotT(timestamp));
}
/// Copy and insert a snapshot
EntitySnapshotT& addSnapshot(const EntitySnapshotT& snapshot)
{
return addSnapshot(EntitySnapshotT(snapshot));
return this->addSnapshot(snapshot.time(), EntitySnapshotT(snapshot));
}
/// Move and insert a snapshot
EntitySnapshotT& addSnapshot(EntitySnapshotT&& snapshot)
{
auto it = this->_container.emplace_hint(this->_container.end(), snapshot.time(), std::move(snapshot));
it->second.id().setEntityID(this->id());
return it->second;
Time timestamp = snapshot.time(); // Copy before move.
return this->addSnapshot(timestamp, std::move(snapshot));
}
EntitySnapshotT& addSnapshot(const Time& timestamp)
/// Insert a snapshot in-place.
template <class ...Args>
EntitySnapshotT& addSnapshot(const Time& timestamp, Args... args)
{
return addSnapshot(EntitySnapshotT(timestamp, this->id()));
auto it = this->_container.emplace_hint(this->_container.end(), timestamp, args...);
it->second.id() = this->id().withTimestamp(timestamp);
return it->second;
}
......
......@@ -223,7 +223,8 @@ namespace armarx::armem::base
/// Move and insert a core segment.
CoreSegmentT& addCoreSegment(CoreSegmentT&& coreSegment)
{
return this->_derived().addCoreSegment(coreSegment.name(), std::move(coreSegment));
const std::string name = coreSegment.name(); // Copy before move.
return this->_derived().addCoreSegment(name, std::move(coreSegment));
}
/// Move and insert a core segment.
......
......@@ -231,8 +231,6 @@ namespace armarx::armem::base
void append(const DerivedT& m)
{
// ARMARX_INFO << "ProviderSegment: Merge name '" << m.name() << "' into '" << name() << "'";
m.forEachEntity([this](const EntityT & entity)
{
auto it = this->_container.find(entity.name());
......@@ -261,7 +259,8 @@ namespace armarx::armem::base
/// Move and insert an entity.
EntityT& addEntity(EntityT&& entity)
{
return this->_derived().addEntity(entity.name(), std::move(entity));
const std::string name = entity.name(); // Copy before move.
return this->_derived().addEntity(name, std::move(entity));
}
/// Insert an entity in-place.
......@@ -278,7 +277,6 @@ namespace armarx::armem::base
bool equalsDeep(const DerivedT& other) const
{
//std::cout << "ProviderSegment::equalsDeep" << std::endl;
if (this->size() != other.size())
{
return false;
......
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