Entity Class Reference

#include <RobotAPI/libraries/armem/server/wm/memory_definitions.h>

+ Inheritance diagram for Entity:

Public Member Functions

void setMaxHistorySize (long maxSize)
 Sets the maximum history size.
 
UpdateResult update (const EntityUpdate &update)
 
- Public Member Functions inherited from EntityBase< EntitySnapshot, Entity >
EntitySnapshotT & addSnapshot (const EntitySnapshotT &snapshot)
 Copy and insert a snapshot.
 
EntitySnapshotT & addSnapshot (const Time &timestamp)
 Add a snapshot at the given time.
 
EntitySnapshotT & addSnapshot (const Time &timestamp, Args... args)
 Insert a snapshot in-place.
 
EntitySnapshotT & addSnapshot (EntitySnapshotT &&snapshot)
 Move and insert a snapshot.
 
void append (const OtherDerivedT &other)
 
 EntityBase ()
 
 EntityBase (const EntityBase &other)=default
 
 EntityBase (const MemoryID &id)
 
 EntityBase (const std::string &name, const MemoryID &parentID={})
 
 EntityBase (EntityBase &&other)=default
 
bool equalsDeep (const DerivedT &other) const
 
EntitySnapshotT * findFirstSnapshot ()
 Return the snapshot with the least recent timestamp.
 
const EntitySnapshotT * findFirstSnapshot () const
 
const EntitySnapshotT * findFirstSnapshotAfter (const Time &time) const
 Return first snapshot after time.
 
const EntitySnapshotT * findFirstSnapshotAfterOrAt (const Time &time) const
 Return first snapshot after or at time.
 
auto * findLatestInstance (int instanceIndex=0)
 
const auto * findLatestInstance (int instanceIndex=0) const
 
EntitySnapshotT * findLatestSnapshot ()
 Return the snapshot with the most recent timestamp.
 
const EntitySnapshotT * findLatestSnapshot () const
 
const EntitySnapshotT * findLatestSnapshotBefore (const Time &time) const
 Return the lastest snapshot before time.
 
const EntitySnapshotT * findLatestSnapshotBeforeOrAt (const Time &time) const
 Return the latest snapshot before or at time.
 
EntitySnapshotT * findSnapshot (const MemoryID &snapshotID)
 
const EntitySnapshotT * findSnapshot (const MemoryID &snapshotID) const
 
EntitySnapshotT * findSnapshot (const Time &timestamp)
 
const EntitySnapshotT * findSnapshot (const Time &timestamp) const
 
bool forEachInstanceIn (const MemoryID &id, InstanceFunctionT &&func)
 
bool forEachInstanceIn (const MemoryID &id, InstanceFunctionT &&func) const
 
bool forEachSnapshot (SnapshotFunctionT &&func)
 
bool forEachSnapshot (SnapshotFunctionT &&func) const
 
void forEachSnapshotBefore (const Time &time, FunctionT &&func) const
 Return all snapshots before (excluding) time.
 
void forEachSnapshotBeforeOrAt (const Time &time, FunctionT &&func) const
 Return all snapshots before or at time.
 
void forEachSnapshotBeforeReverse (const Time &time, FunctionT &&func) const
 Iterate over all snapshots before (excluding) time in reverse order (newest first).
 
bool forEachSnapshotIn (const MemoryID &id, SnapshotFunctionT &&func)
 
bool forEachSnapshotIn (const MemoryID &id, SnapshotFunctionT &&func) const
 
void forEachSnapshotInIndexRange (long first, long last, FunctionT &&func) const
 Return all snapshots from first to last index.
 
void forEachSnapshotInTimeRange (const Time &min, const Time &max, FunctionT &&func) const
 Return all snapshots between, including, min and max.
 
EntitySnapshotT & getFirstSnapshot ()
 Return the snapshot with the least recent timestamp.
 
const EntitySnapshotT & getFirstSnapshot () const
 
Time getFirstTimestamp () const
 Get the oldest timestamp.
 
std::string getKeyString () const
 
Time getLatestTimestamp () const
 Get the latest timestamp.
 
EntitySnapshotT & getSnapshot (const MemoryID &snapshotID)
 
const EntitySnapshotT & getSnapshot (const MemoryID &snapshotID) const
 
EntitySnapshotT & getSnapshot (const Time &time)
 Get a snapshot.
 
const EntitySnapshotT & getSnapshot (const Time &time) const
 
std::vector< Time > getTimestamps () const
 Get all timestamps in the history.
 
bool hasSnapshot (const MemoryID &snapshotID) const
 Indicate whether a snapshot with the given ID exists.
 
bool hasSnapshot (const Time &time) const
 Indicate whether a snapshot at the given time exists.
 
bool hasSnapshots () const
 Indicate whether the entity has any snapshots.
 
std::string & name ()
 
const std::string & name () const
 
EntityBase & operator= (const EntityBase &other)=default
 
EntityBase & operator= (EntityBase &&other)=default
 
UpdateResult update (const EntityUpdate &update)
 Add the given update to this entity's history.
 
- Public Member Functions inherited from MemoryContainerBase< std::map< Time, EntitySnapshot >, Entity >
ContainerT::iterator begin ()
 
ContainerT::const_iterator begin () const
 
void clear ()
 
bool empty () const
 
ContainerT::iterator end ()
 
ContainerT::const_iterator end () const
 
bool forEachChild (ChildFunctionT &&func)
 
bool forEachChild (ChildFunctionT &&func) const
 
 MemoryContainerBase ()
 
 MemoryContainerBase (const MemoryContainerBase &other)=default
 
 MemoryContainerBase (const MemoryID &id)
 
 MemoryContainerBase (MemoryContainerBase &&other)=default
 
MemoryContainerBase & operator= (const MemoryContainerBase &other)=default
 
MemoryContainerBase & operator= (MemoryContainerBase &&other)=default
 
std::size_t size () const
 
- Public Member Functions inherited from MemoryItem
MemoryID & id ()
 
const MemoryID & id () const
 
 MemoryItem ()
 
 MemoryItem (const MemoryID &id)
 
 MemoryItem (const MemoryItem &other)=default
 
 MemoryItem (MemoryItem &&other)=default
 
MemoryItem & operator= (const MemoryItem &other)=default
 
MemoryItem & operator= (MemoryItem &&other)=default
 
- Public Member Functions inherited from ForEachEntityInstanceMixin< Entity >
bool forEachInstance (InstanceFunctionT &&func)
 
bool forEachInstance (InstanceFunctionT &&func) const
 
bool forEachInstanceAs (AronDtoFunctionT &&func) const
 Call func on the data of each instance converted to Aron DTO class.
 
bool forEachInstanceWithDataAs (EntityInstanceBaseAronDtoFunctionT &&func) const
 Call func on each instance with its data converted to Aron DTO class.
 
- Public Member Functions inherited from GetFindInstanceMixin< Entity >
auto * findInstance (const MemoryID &instanceID)
 Find an entity instance.
 
const auto * findInstance (const MemoryID &instanceID) const
 
auto & getInstance (const MemoryID &instanceID)
 Retrieve an entity instance.
 
const auto & getInstance (const MemoryID &instanceID) const
 
bool hasInstance (const MemoryID &instanceID) const
 Indicate whether this container has an instance with the given ID.
 
bool hasInstances () const
 Indicate whether this container contains at least one entity instance.
 
- Public Member Functions inherited from GetLatestInstanceMixin< Entity >
auto & getLatestInstance (int instanceIndex=0)
 Retrieve the latest entity instance.
 
const auto & getLatestInstance (int instanceIndex=0) const
 
- Public Member Functions inherited from GetLatestSnapshotMixin< Entity >
auto & getLatestSnapshot (int snapshotIndex=0)
 Retrieve the latest entity snapshot.
 
const auto & getLatestSnapshot (int snapshotIndex=0) const
 
- Public Member Functions inherited from MaxHistorySize
long getMaxHistorySize () const
 
size_t getTruncateMaxBatchSize () const
 
size_t getUnlimitedHistoryWarningThreshold () const
 
void setMaxHistorySize (long maxSize, const std::string &additionalInfo="")
 Set the maximum number of snapshots to be contained in an entity.
 
void setTruncateMaxBatchSize (size_t batchSize)
 Set the maximum number of snapshots to remove per truncate() call.
 
void setUnlimitedHistoryWarningThreshold (size_t threshold)
 Set the threshold for warning about unlimited history growth.
 
- Public Member Functions inherited from FindInstanceDataMixinForEntity< Entity >
aron::data::DictPtr findLatestInstanceData (int instanceIndex=0) const
 
std::optional< AronDtoT > findLatestInstanceDataAs (int instanceIndex=0) const
 

Protected Member Functions

std::vector< EntitySnapshotT > truncate ()
 If maximum size is set, ensure history's is not higher.
 
- Protected Member Functions inherited from MemoryContainerBase< std::map< Time, EntitySnapshot >, Entity >
ChildT & _addChild (const KeyT &key, ChildArgs... childArgs)
 
void _checkContainerName (const std::string &gottenName, const std::string &actualName, bool emptyOk=true) const
 
DerivedT & _derived ()
 
const DerivedT & _derived () const
 
ContainerT & container ()
 
const ContainerT & container () const
 
- Protected Member Functions inherited from MemoryItem
 ~MemoryItem ()
 

Additional Inherited Members

- Public Types inherited from EntityBase< EntitySnapshot, Entity >
using ChildT
 
using EntityInstanceT
 
using EntitySnapshotT
 
- Public Types inherited from MemoryContainerBase< std::map< Time, EntitySnapshot >, Entity >
using ContainerT
 
using DerivedT
 
- Static Public Member Functions inherited from EntityBase< EntitySnapshot, Entity >
static std::string getLevelName ()
 
- Protected Attributes inherited from MemoryContainerBase< std::map< Time, EntitySnapshot >, Entity >
ContainerT _container
 
- Protected Attributes inherited from MemoryItem
MemoryID _id
 
- Protected Attributes inherited from MaxHistorySize
long _maxHistorySize = 120000
 Maximum size of entity histories.
 
size_t _truncateMaxBatchSize = 100
 Maximum number of snapshots to remove per truncate() call.
 
size_t _unlimitedHistoryWarningThreshold = 500000
 Threshold for warning about unlimited history growth.
 

Detailed Description

See also
base::EntityBase

Definition at line 82 of file memory_definitions.h.

Member Function Documentation

◆ setMaxHistorySize()

void setMaxHistorySize ( long maxSize)

Sets the maximum history size.

The current history is truncated if necessary.

Definition at line 19 of file memory_definitions.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ truncate()

std::vector< EntitySnapshot > truncate ( )
protected

If maximum size is set, ensure history's is not higher.

Definition at line 35 of file memory_definitions.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

auto update ( const EntityUpdate & update)

Definition at line 27 of file memory_definitions.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: