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)
60 throw armem::error::MissingEntry::create<typename ParentT::ChildT>(keyStringFn(key),
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>
93 derived<DerivedT>(
this).forEachInstance(
94 [&has](
const auto& snapshot)
110 return derived<DerivedT>(
this).findInstance(instanceID) !=
nullptr;
121 auto* snapshot = derived<DerivedT>(
this).findSnapshot(instanceID);
122 return snapshot ? snapshot->findInstance(instanceID) :
nullptr;
128 const auto* snapshot = derived<DerivedT>(
this).findSnapshot(instanceID);
129 return snapshot ? snapshot->findInstance(instanceID) :
nullptr;
141 return derived<DerivedT>(
this).getSnapshot(instanceID).getInstance(instanceID);
147 return derived<DerivedT>(
this).getSnapshot(instanceID).getInstance(instanceID);
151 template <
class DerivedT>
165 auto* instance = derived<DerivedT>(
this).findLatestInstance();
169 "entity instances", DerivedT::getLevelName(), derived<DerivedT>(
this).
id());
177 const auto* instance = derived<DerivedT>(
this).findLatestInstance();
181 "entity instances", DerivedT::getLevelName(), derived<DerivedT>(
this).
id());
187 template <
class DerivedT>
201 auto* snapshot = derived<DerivedT>(
this).findLatestSnapshot();
205 "entity snapshots", DerivedT::getLevelName(), derived<DerivedT>(
this).
id());
213 const auto* snapshot = derived<DerivedT>(
this).findLatestSnapshot();
217 "entity snapshots", DerivedT::getLevelName(), derived<DerivedT>(
this).
id());
223 template <
class DerivedT>
238 derived<DerivedT>(
this).forEachSnapshot(
239 [&has](
const auto& snapshot)
255 return derived<DerivedT>(
this).findSnapshot(snapshotID) !=
nullptr;
268 auto* entity = derived<DerivedT>(
this).findEntity(snapshotID);
269 return entity ? entity->findSnapshot(snapshotID) :
nullptr;
275 auto* entity = derived<DerivedT>(
this).findEntity(snapshotID);
276 return entity ? entity->findSnapshot(snapshotID) :
nullptr;
288 return derived<DerivedT>(
this).getEntity(snapshotID).getSnapshot(snapshotID);
294 return derived<DerivedT>(
this).getEntity(snapshotID).getSnapshot(snapshotID);
306 const typename DerivedT::EntitySnapshotT* latestSnapshot =
nullptr;
307 derived<DerivedT>(
this).forEachEntity(
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;
327 derived<DerivedT>(
this).forEachEntity(
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;
354 auto* entity = derived<DerivedT>(
this).findEntity(entityID);
355 return entity ? entity->findLatestSnapshot() :
nullptr;
361 auto* entity = derived<DerivedT>(
this).findEntity(entityID);
362 return entity ? entity->findLatestSnapshot() :
nullptr;
374 auto* snapshot = derived<DerivedT>(
this).findLatestSnapshot();
375 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
381 auto* snapshot = derived<DerivedT>(
this).findLatestSnapshot();
382 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
396 auto* snapshot = derived<DerivedT>(
this).findLatestSnapshot(entityID);
397 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
403 auto* snapshot = derived<DerivedT>(
this).findLatestSnapshot(entityID);
404 return snapshot ? snapshot->findInstance(instanceIndex) :
nullptr;
408 template <
class DerivedT>
416 return derived<DerivedT>(
this).findEntity(entityID) !=
nullptr;
427 auto* provSeg = derived<DerivedT>(
this).findProviderSegment(entityID);
428 return provSeg ? provSeg->findEntity(entityID) :
nullptr;
434 auto* provSeg = derived<DerivedT>(
this).findProviderSegment(entityID);
435 return provSeg ? provSeg->findEntity(entityID) :
nullptr;
447 return derived<DerivedT>(
this).getProviderSegment(entityID).getEntity(entityID);
453 return derived<DerivedT>(
this).getProviderSegment(entityID).getEntity(entityID);
457 template <
class DerivedT>
465 return derived<DerivedT>(
this).findProviderSegment(providerSegmentID) !=
nullptr;
476 auto* provSeg = derived<DerivedT>(
this).findCoreSegment(providerSegmentID);
477 return provSeg ? provSeg->findProviderSegment(providerSegmentID) :
nullptr;
483 auto* provSeg = derived<DerivedT>(
this).findCoreSegment(providerSegmentID);
484 return provSeg ? provSeg->findProviderSegment(providerSegmentID) :
nullptr;
496 return derived<DerivedT>(
this)
497 .getCoreSegment(providerSegmentID)
498 .getProviderSegment(providerSegmentID);
504 return derived<DerivedT>(
this)
505 .getCoreSegment(providerSegmentID)
506 .getProviderSegment(providerSegmentID);