21 template <
class _Prov
iderSegmentT,
class _Derived>
41 using EntityT =
typename ProviderSegmentT::EntityT;
110 inline const std::string&
197 return this->
findEntity(entityName) !=
nullptr;
217 template <
class Prov
iderSegmentFunctionT>
227 template <
class Prov
iderSegmentFunctionT>
242 template <
class InstanceFunctionT>
249 id.hasProviderSegmentName(),
250 id.hasProviderSegmentName()
258 template <
class InstanceFunctionT>
265 id.hasProviderSegmentName(),
266 id.hasProviderSegmentName()
272 std::vector<std::string>
275 return simox::alg::get_keys(this->
_container);
290 auto [inserted, provSeg] =
295 UpdateResult ret(provSeg->update(
update));
307 template <
class OtherDerivedT>
311 other.forEachProviderSegment(
312 [
this](
const auto& provSeg)
314 auto it = this->
_container.find(provSeg.name());
318 .emplace(provSeg.name(),
319 this->id().withProviderSegmentName(provSeg.name()))
321 it->second.aronType() = provSeg.aronType();
332 it->second.append(provSeg);
351 providerSegmentType ? providerSegmentType : this->
aronType();
359 return this->
_derived().addProviderSegment(providerSegment.name(),
367 const std::string
name = providerSegment.name();
368 return this->
_derived().addProviderSegment(name, std::move(providerSegment));
372 template <
class... Args>
387 if (this->
size() != other.size())
391 for (
const auto& [key, provider] : this->
_container)
393 if (not other.hasProviderSegment(key))
397 if (not provider.equalsDeep(other.getProviderSegment(key)))
408 return "core segment";
419 template <
class ParentT>
423 decltype(parent.findEntity(entityName)) result =
nullptr;
424 parent.forEachProviderSegment(
425 [&result, &entityName](
auto& provSeg)
427 result = provSeg.findEntity(entityName);
428 return result ==
nullptr;
433 std::pair<bool, ProviderSegmentT*>
438 auto it = this->
_container.find(providerSegmentName);
441 if (_addMissingProviderSegmentDuringUpdate)
445 return {
true, provSeg};
454 provSeg = &it->second;
455 return {
false, provSeg};
461 bool _addMissingProviderSegmentDuringUpdate =
true;
std::string coreSegmentName
MemoryID withProviderSegmentName(const std::string &name) const
std::string providerSegmentName
Data of a core segment containing multiple provider segments.
CoreSegmentBase(const MemoryID &id, aron::type::ObjectPtr aronType=nullptr, const std::vector< PredictionEngine > &predictionEngines={})
typename ProviderSegmentT::EntityT EntityT
typename EntityT::EntitySnapshotT EntitySnapshotT
CoreSegmentBase(const std::string &name, aron::type::ObjectPtr aronType=nullptr, const std::vector< PredictionEngine > &predictionEngines={})
bool forEachInstanceIn(const MemoryID &id, InstanceFunctionT &&func)
EntityT * findEntity(const std::string &entityName)
bool hasProviderSegment(const MemoryID &providerSegmentID) const
ProviderSegmentT & addProviderSegment(const std::string &name, aron::type::ObjectPtr providerSegmentType=nullptr, const std::vector< PredictionEngine > &predictionEngines={})
Add an empty provider segment with the given name, optional provider segment type and prediction engi...
static auto * _findEntity(ParentT &&parent, const std::string &entityName)
const std::string & name() const
CoreSegmentBase & operator=(const CoreSegmentBase &other)=default
CoreSegmentBase(const std::string &name, const MemoryID &parentID, aron::type::ObjectPtr aronType=nullptr, const std::vector< PredictionEngine > &predictionEngines={})
_ProviderSegmentT ProviderSegmentT
bool equalsDeep(const DerivedT &other) const
bool hasProviderSegment(const std::string &name) const
bool forEachProviderSegment(ProviderSegmentFunctionT &&func)
ProviderSegmentT & addProviderSegment(ProviderSegmentT &&providerSegment)
Move and insert a provider segment.
const ProviderSegmentT & getProviderSegment(const MemoryID &providerSegmentID) const
bool hasEntity(const std::string &entityName) const
const ProviderSegmentT * findProviderSegment(const std::string &name) const
bool forEachInstanceIn(const MemoryID &id, InstanceFunctionT &&func) const
const EntityT * findEntity(const std::string &entityName) const
ProviderSegmentT * findProviderSegment(const MemoryID &providerSegmentID)
static std::string getLevelName()
const ProviderSegmentT & getProviderSegment(const std::string &name) const
void append(const OtherDerivedT &other)
typename EntitySnapshotT::EntityInstanceT EntityInstanceT
std::vector< std::string > getProviderSegmentNames() const
ProviderSegmentT & getProviderSegment(const std::string &name)
std::pair< bool, ProviderSegmentT * > _addProviderSegmentIfMissing(const std::string &providerSegmentName)
CoreSegmentBase & operator=(CoreSegmentBase &&other)=default
ProviderSegmentT & addProviderSegment(const std::string &name, Args... args)
Insert a provider segment in-place.
ProviderSegmentT & addProviderSegment(const ProviderSegmentT &providerSegment)
Copy and insert a provider segment.
ProviderSegmentT & getProviderSegment(const MemoryID &providerSegmentID)
std::string getKeyString() const
CoreSegmentBase(CoreSegmentBase &&other)=default
UpdateResult update(const EntityUpdate &update)
Updates an entity's history.
ProviderSegmentT * findProviderSegment(const std::string &name)
const ProviderSegmentT * findProviderSegment(const MemoryID &providerSegmentID) const
CoreSegmentBase(const CoreSegmentBase &other)=default
bool forEachProviderSegment(ProviderSegmentFunctionT &&func) const
Something with a specific ARON type.
aron::type::ObjectPtr & aronType()
AronTyped(aron::type::ObjectPtr aronType=nullptr)
Provides default implmentations of MemoryContainer, as well as iterators (which requires a template).
bool forEachChild(ChildFunctionT &&func)
std::map< std::string, _ProviderSegmentT > ContainerT
ChildT & _addChild(const KeyT &key, ChildArgs... childArgs)
void _checkContainerName(const std::string &gottenName, const std::string &actualName, bool emptyOk=true) const
Something that supports a set of prediction engines.
const std::vector< PredictionEngine > & predictionEngines() const
static MissingEntry create(const std::string &missingKey, const ContainerT &container)
void checkHasProviderSegmentName(const MemoryID &providerSegmentID)
Throw armem::error::InvalidMemoryID if the given ID has provider segment name.
auto & getChildByKey(const KeyT &key, ContainerT &&container, const ParentT &owner, KeyStringFn &&keyStringFn)
Retrieve a child in a container by its key.
bool forEachInstanceIn(const MemoryID &id, FunctionT &&func, ParentT &parent, bool single, ChildT *child)
auto * findChildByKey(const KeyT &key, ContainerT &&container)
Find a child in a container by its key.
UpdateType
The type of an update.
std::shared_ptr< Object > ObjectPtr
An update of an entity for a specific point in time.
MemoryID entityID
The entity's ID.
std::vector< EntitySnapshotT > updatedSnapshots
armarx::armem::UpdateType coreSegmentUpdateType
armarx::armem::UpdateType entityUpdateType
std::vector< EntitySnapshotT > removedSnapshots
UpdateResult(const typename ProviderSegmentT::UpdateResult &c)
armarx::armem::UpdateType providerSegmentUpdateType