30 template <
class KeyT,
class ContainerT>
34 auto it = container.find(key);
35 return it != container.end() ? &it->second :
nullptr;
47 template <
class KeyT,
class ContainerT,
class ParentT,
class KeyStringFn>
50 ContainerT&& container,
52 KeyStringFn&& keyStringFn)
73 template <
class KeyT,
class ContainerT,
class ParentT>
75 getChildByKey(
const KeyT& key, ContainerT&& container,
const ParentT& parent)
77 return getChildByKey(key, container, parent, [](
const KeyT& key) {
return key; });
80 template <
class DerivedT>
94 [&has](
const auto& snapshot)
122 return snapshot ? snapshot->findInstance(instanceID) :
nullptr;
129 return snapshot ? snapshot->findInstance(instanceID) :
nullptr;
151 template <
class DerivedT>
187 template <
class DerivedT>
223 template <
class DerivedT>
239 [&has](
const auto& snapshot)
269 return entity ? entity->findSnapshot(snapshotID) :
nullptr;
276 return entity ? entity->findSnapshot(snapshotID) :
nullptr;
306 const typename DerivedT::EntitySnapshotT* latestSnapshot =
nullptr;
308 [&latestSnapshot](
const auto& entity)
310 const auto* snapshot = entity.findLatestSnapshot();
311 if (latestSnapshot ==
nullptr)
313 latestSnapshot = snapshot;
315 else if (snapshot and snapshot->time() > latestSnapshot->time())
317 latestSnapshot = snapshot;
320 return latestSnapshot;
326 typename DerivedT::EntitySnapshotT* latestSnapshot =
nullptr;
328 [&latestSnapshot](
auto& entity)
330 auto* snapshot = entity.findLatestSnapshot();
331 if (latestSnapshot ==
nullptr)
333 latestSnapshot = snapshot;
335 else if (snapshot and snapshot->time() > latestSnapshot->time())
337 latestSnapshot = snapshot;
340 return latestSnapshot;
355 return entity ? entity->findLatestSnapshot() :
nullptr;
362 return entity ? entity->findLatestSnapshot() :
nullptr;
375 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
382 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
397 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
404 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
408 template <
class DerivedT>
428 return provSeg ? provSeg->findEntity(entityID) :
nullptr;
435 return provSeg ? provSeg->findEntity(entityID) :
nullptr;
457 template <
class DerivedT>
465 return derived<DerivedT>(
this).findProviderSegment(providerSegmentID) !=
nullptr;
477 return provSeg ? provSeg->findProviderSegment(providerSegmentID) :
nullptr;
484 return provSeg ? provSeg->findProviderSegment(providerSegmentID) :
nullptr;
497 .getCoreSegment(providerSegmentID)
498 .getProviderSegment(providerSegmentID);
505 .getCoreSegment(providerSegmentID)
506 .getProviderSegment(providerSegmentID);
static MissingEntry create(const std::string &missingKey, const ContainerT &container)
Indicates that an operation requiring at least one element to exist failed because there were no such...
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.
void checkHasInstanceIndex(const MemoryID &instanceID)
Throw armem::error::InvalidMemoryID if the given ID has no instance index.
void checkHasMemoryName(const MemoryID &memory)
Throw armem::error::InvalidMemoryID if the given ID has memory name.
DerivedT & derived(ThisT *t)
void checkHasEntityName(const MemoryID &entityID)
Throw armem::error::InvalidMemoryID if the given ID has no entity name.
void checkHasTimestamp(const MemoryID &snapshotID)
Throw armem::error::InvalidMemoryID if the given ID has no timestamp.
void checkHasCoreSegmentName(const MemoryID &coreSegmentID)
Throw armem::error::InvalidMemoryID if the given ID has core segment name.
auto * findChildByKey(const KeyT &key, ContainerT &&container)
Find a child in a container by its key.
auto & getEntity(const MemoryID &entityID)
Retrieve an entity.
auto * findEntity(const MemoryID &entityID)
Find an entity.
const auto * findEntity(const MemoryID &entityID) const
const auto & getEntity(const MemoryID &entityID) const
bool hasEntity(const MemoryID &entityID) const
bool hasInstance(const MemoryID &instanceID) const
Indicate whether this container has an instance with the given ID.
auto & getInstance(const MemoryID &instanceID)
Retrieve an entity instance.
const auto & getInstance(const MemoryID &instanceID) const
bool hasInstances() const
Indicate whether this container contains at least one entity instance.
auto * findInstance(const MemoryID &instanceID)
Find an entity instance.
const auto * findInstance(const MemoryID &instanceID) const
auto & getProviderSegment(const MemoryID &providerSegmentID)
Retrieve a provider segment.
auto * findProviderSegment(const MemoryID &providerSegmentID)
Retrieve a provider segment.
bool hasProviderSegment(const MemoryID &providerSegmentID) const
const auto & getProviderSegment(const MemoryID &providerSegmentID) const
const auto * findProviderSegment(const MemoryID &providerSegmentID) const
auto * findLatestSnapshot()
bool hasSnapshots() const
Indicate whether this container contains at least one entity snapshot.
auto & getSnapshot(const MemoryID &snapshotID)
Retrieve an entity snapshot.
const auto * findLatestSnapshot() const
Find the latest entity snapshot.
auto * findLatestSnapshot(const MemoryID &entityID)
Find the latest entity snapshot in the given entity.
auto * findSnapshot(const MemoryID &snapshotID)
Find an entity snapshot.
const auto * findLatestInstance(const MemoryID &entityID, int instanceIndex=0) const
bool hasSnapshot(const MemoryID &snapshotID) const
Indicates whether a snapshot with the given ID exists.
auto * findLatestInstance(const MemoryID &entityID, int instanceIndex=0)
Find the latest entity instance in the given entity.
const auto * findLatestInstance(int instanceIndex=0) const
Find the latest entity instance.
const auto & getSnapshot(const MemoryID &snapshotID) const
const auto * findLatestSnapshot(const MemoryID &entityID) const
const auto * findSnapshot(const MemoryID &snapshotID) const
auto * findLatestInstance(int instanceIndex=0)
auto & getLatestInstance(int instanceIndex=0)
Retrieve the latest entity instance.
const auto & getLatestInstance(int instanceIndex=0) const
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
const auto & getLatestSnapshot(int snapshotIndex=0) const