Go to the documentation of this file.
5 #include <SimoxUtility/algorithm/string.h>
27 const std::string& exportName,
29 const std::shared_ptr<Processors>& filters) :
30 EntityBase(exportName, id, filters),
31 DiskMemoryItemMixin(p, exportName, id),
32 MongoDBStorageMixin(
s, exportName, id)
50 <<
"' with name '" << d.filename() <<
"'. "
51 <<
"Ignoring this folder, however this is a bad situation.";
60 ARMARX_WARNING <<
"Found a non-timestamp folder inside an entity '"
61 <<
id().
str() <<
"' hours folder with name '" <<
s.filename()
63 <<
"Ignoring this folder, however this is a bad situation.";
72 <<
"Found a non-timestamp folder inside an entity '" <<
id().
str()
73 <<
"' seconds folder with name '" << us.filename() <<
"'. "
74 <<
"Ignoring this folder, however this is a bad situation.";
102 if (first < 0 or last < 0)
105 unsigned long size = 0;
116 if (checked >= first && checked <= last)
134 auto ts = e.id().timestamp;
135 if (ts >=
min && ts <=
max)
151 auto ts = e.id().timestamp;
167 auto ts = e.id().timestamp;
187 id().withTimestamp(n),
189 return c.fullPathExists();
194 std::shared_ptr<EntitySnapshot>
202 return std::make_shared<EntitySnapshot>(
206 std::shared_ptr<EntitySnapshot>
213 auto ts = e.id().timestamp;
230 id().withTimestamp(bestMatch),
234 std::shared_ptr<EntitySnapshot>
241 auto ts = e.id().timestamp;
242 if (ts < time && ts > bestMatch)
258 id().withTimestamp(bestMatch),
262 std::shared_ptr<EntitySnapshot>
269 auto ts = e.id().timestamp;
270 if (ts <= time && ts > bestMatch)
286 id().withTimestamp(bestMatch),
290 std::shared_ptr<EntitySnapshot>
297 auto ts = e.id().timestamp;
298 if (ts > time && ts < bestMatch)
314 id().withTimestamp(bestMatch),
318 std::shared_ptr<EntitySnapshot>
325 auto ts = e.id().timestamp;
326 if (ts >= time && ts < bestMatch)
342 id().withTimestamp(bestMatch),
359 armem::wm::EntitySnapshot s;
360 x.loadAllReferences(s);
375 [&e, &count](
auto& x)
384 [&e, &n, ¤t, &count](
auto& x)
390 if (current >= (count - n)){
391 ARMARX_INFO << e.id().coreSegmentName <<
": count: " << count <<
", n: " << n <<
", current: " << current;
392 ARMARX_DEBUG <<
"Loading snapshot with timestamp " << x.id().timestamp <<
" into WM";
393 armem::wm::EntitySnapshot s;
394 x.loadAllReferences(s);
397 ARMARX_DEBUG <<
"Skipping snapshot with timestamp " << x.id().timestamp;
407 std::lock_guard l(ltm_mutex);
409 if ( fullPathExists())
418 id().withTimestamp(e.id().timestamp),
428 std::lock_guard l(ltm_mutex);
429 if (
id().entityName.empty())
432 <<
"During storage of segment '" <<
c.id().str()
433 <<
"' I noticed that the corresponding LTM has no id set. "
434 <<
"I set the id of the LTM to the same name, however this should not happen!";
435 id().entityName =
c.id().entityName;
447 [&](
const auto& snap)
452 id().withTimestamp(snap.id().timestamp),
457 if (hasSnapshot(snap.id().timestamp))
459 ARMARX_INFO <<
"Ignoring to put an EntitiySnapshot into the LTM because "
460 "the timestamp already existed (we assume snapshots are "
461 "const and do not change outside the ltm).";
465 for (
auto& f : processors->snapFilters)
468 bool accepted = f->accept(snap);
479 statistics.recordedSnapshots++;
bool forEachSnapshotBefore(const Time &time, std::function< void(EntitySnapshot &)> func) const override
std::shared_ptr< Processors > processors
std::shared_ptr< EntitySnapshot > findLatestSnapshotBefore(const Time &time) const override
Path getMemoryBasePath() const
void _loadLatestNReferences(int n, armem::wm::Entity &e) override
std::shared_ptr< EntitySnapshot > findFirstSnapshotAfterOrAt(const Time &time) const override
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Time timeFromStringMicroSeconds(const std::string µSeconds)
Get a Time from the microseconds as text.
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::shared_ptr< EntitySnapshot > findFirstSnapshotAfter(const Time &time) const override
bool forEachSnapshot(std::function< void(EntitySnapshot &)> func) const override
iterate over all entity snapshots of this ltm
bool hasSnapshot(const Time &) const override
check if snapshot segment exists
bool forEachSnapshotInTimeRange(const Time &min, const Time &max, std::function< void(EntitySnapshot &)> func) const override
std::vector< Path > getAllDirectories() const
std::shared_ptr< EntitySnapshot > findSnapshot(const Time &) const override
find entity snapshot segment
size_t negativeIndexSemantics(long index, size_t size)
bool forEachSnapshotBeforeOrAt(const Time &time, std::function< void(EntitySnapshot &)> func) const override
std::vector< std::filesystem::path > getAllDirectories(const std::filesystem::path &p)
MongoDBSettings getSettings() const
virtual std::string getExportName() const
std::recursive_mutex ltm_mutex
bool isNumberString(const std::string &s)
armarx::core::time::DateTime Time
Entity(const detail::mixin::Path &, const detail::mixin::MongoDBSettings &, const std::string &, const MemoryID &id, const std::shared_ptr< Processors > &)
void _loadAllReferences(armem::wm::Entity &) override
Represents a point in time.
MemoryID getEntityID() const
armem::wm::EntitySnapshot EntitySnapshot
bool forEachSnapshotInIndexRange(long first, long last, std::function< void(EntitySnapshot &)> func) const override
bool hasSnapshot(const Time &time) const
Indicate whether a snapshot at the given time exists.
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
bool isDateString(const std::string &s)
bool fullPathExists() const
std::shared_ptr< EntitySnapshot > findLatestSnapshot() const override
std::shared_ptr< EntitySnapshot > findLatestSnapshotBeforeOrAt(const Time &time) const override
std::filesystem::path Path
bool forEachSnapshot(SnapshotFunctionT &&func)
Client-side working memory entity.
static Duration MicroSeconds(std::int64_t microSeconds)
Constructs a duration in microseconds.
double s(double t, double s0, double v0, double a0, double j)
static DateTime Invalid()