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. More...
 
UpdateResult update (const EntityUpdate &update)
 
- Public Member Functions inherited from EntityBase< EntitySnapshot, Entity >
EntitySnapshotTaddSnapshot (const EntitySnapshotT &snapshot)
 Copy and insert a snapshot. More...
 
EntitySnapshotTaddSnapshot (const Time &timestamp)
 Add a snapshot at the given time. More...
 
EntitySnapshotTaddSnapshot (const Time &timestamp, Args... args)
 Insert a snapshot in-place. More...
 
EntitySnapshotTaddSnapshot (EntitySnapshotT &&snapshot)
 Move and insert a snapshot. More...
 
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
 
EntitySnapshotTfindFirstSnapshot ()
 Return the snapshot with the least recent timestamp. More...
 
const EntitySnapshotTfindFirstSnapshot () const
 
const EntitySnapshotTfindFirstSnapshotAfter (const Time &time) const
 Return first snapshot after time. More...
 
const EntitySnapshotTfindFirstSnapshotAfterOrAt (const Time &time) const
 Return first snapshot after or at time. More...
 
auto * findLatestInstance (int instanceIndex=0)
 
const auto * findLatestInstance (int instanceIndex=0) const
 
EntitySnapshotTfindLatestSnapshot ()
 Return the snapshot with the most recent timestamp. More...
 
const EntitySnapshotTfindLatestSnapshot () const
 
const EntitySnapshotTfindLatestSnapshotBefore (const Time &time) const
 Return the lastest snapshot before time. More...
 
const EntitySnapshotTfindLatestSnapshotBeforeOrAt (const Time &time) const
 Return the latest snapshot before or at time. More...
 
EntitySnapshotTfindSnapshot (const MemoryID &snapshotID)
 
const EntitySnapshotTfindSnapshot (const MemoryID &snapshotID) const
 
EntitySnapshotTfindSnapshot (const Time &timestamp)
 
const EntitySnapshotTfindSnapshot (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. More...
 
void forEachSnapshotBeforeOrAt (const Time &time, FunctionT &&func) const
 Return all snapshots before or at time. More...
 
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. More...
 
void forEachSnapshotInTimeRange (const Time &min, const Time &max, FunctionT &&func) const
 Return all snapshots between, including, min and max. More...
 
EntitySnapshotTgetFirstSnapshot ()
 Return the snapshot with the least recent timestamp. More...
 
const EntitySnapshotTgetFirstSnapshot () const
 
Time getFirstTimestamp () const
 Get the oldest timestamp. More...
 
std::string getKeyString () const
 
Time getLatestTimestamp () const
 Get the latest timestamp. More...
 
EntitySnapshotTgetSnapshot (const MemoryID &snapshotID)
 
const EntitySnapshotTgetSnapshot (const MemoryID &snapshotID) const
 
EntitySnapshotTgetSnapshot (const Time &time)
 Get a snapshot. More...
 
const EntitySnapshotTgetSnapshot (const Time &time) const
 
std::vector< TimegetTimestamps () const
 Get all timestamps in the history. More...
 
bool hasSnapshot (const MemoryID &snapshotID) const
 Indicate whether a snapshot with the given ID exists. More...
 
bool hasSnapshot (const Time &time) const
 Indicate whether a snapshot at the given time exists. More...
 
bool hasSnapshots () const
 Indicate whether the entity has any snapshots. More...
 
std::string & name ()
 
const std::string & name () const
 
EntityBaseoperator= (const EntityBase &other)=default
 
EntityBaseoperator= (EntityBase &&other)=default
 
UpdateResult update (const EntityUpdate &update)
 Add the given update to this entity's history. More...
 
- 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
 
MemoryContainerBaseoperator= (const MemoryContainerBase &other)=default
 
MemoryContainerBaseoperator= (MemoryContainerBase &&other)=default
 
std::size_t size () const
 
- Public Member Functions inherited from MemoryItem
MemoryIDid ()
 
const MemoryIDid () const
 
 MemoryItem ()
 
 MemoryItem (const MemoryID &id)
 
 MemoryItem (const MemoryItem &other)=default
 
 MemoryItem (MemoryItem &&other)=default
 
MemoryItemoperator= (const MemoryItem &other)=default
 
MemoryItemoperator= (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. More...
 
bool forEachInstanceWithDataAs (EntityInstanceBaseAronDtoFunctionT &&func) const
 Call func on each instance with its data converted to Aron DTO class. More...
 
- Public Member Functions inherited from GetFindInstanceMixin< Entity >
auto * findInstance (const MemoryID &instanceID)
 Find an entity instance. More...
 
const auto * findInstance (const MemoryID &instanceID) const
 
auto & getInstance (const MemoryID &instanceID)
 Retrieve an entity instance. More...
 
const auto & getInstance (const MemoryID &instanceID) const
 
bool hasInstance (const MemoryID &instanceID) const
 Indicate whether this container has an instance with the given ID. More...
 
bool hasInstances () const
 Indicate whether this container contains at least one entity instance. More...
 
- Public Member Functions inherited from GetLatestInstanceMixin< Entity >
auto & getLatestInstance (int instanceIndex=0)
 Retrieve the latest entity instance. More...
 
const auto & getLatestInstance (int instanceIndex=0) const
 
- Public Member Functions inherited from GetLatestSnapshotMixin< Entity >
auto & getLatestSnapshot (int snapshotIndex=0)
 Retrieve the latest entity snapshot. More...
 
const auto & getLatestSnapshot (int snapshotIndex=0) const
 
- Public Member Functions inherited from MaxHistorySize
long getMaxHistorySize () const
 
void setMaxHistorySize (long maxSize)
 Set the maximum number of snapshots to be contained in an entity. More...
 
- 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< EntitySnapshotTtruncate ()
 If maximum size is set, ensure history's is not higher. More...
 
- 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
 
ContainerTcontainer ()
 
const ContainerTcontainer () const
 
- Protected Member Functions inherited from MemoryItem
 ~MemoryItem ()
 

Additional Inherited Members

- Public Types inherited from EntityBase< EntitySnapshot, Entity >
using ChildT = EntitySnapshotT
 
using EntityInstanceT = typename EntitySnapshotT::EntityInstanceT
 
using EntitySnapshotT = EntitySnapshot
 
- Public Types inherited from MemoryContainerBase< std::map< Time, EntitySnapshot >, Entity >
using ContainerT = std::map< Time, EntitySnapshot >
 
using DerivedT = Entity
 
- 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 = -1
 Maximum size of entity histories. More...
 

Detailed Description

See also
base::EntityBase

Definition at line 30 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 17 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 32 of file memory_definitions.cpp.

+ Here is the caller graph for this function:

◆ update()

auto update ( const EntityUpdate update)

Definition at line 24 of file memory_definitions.cpp.

+ Here is the call graph for this function:

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