MemoryID Class Reference

A memory ID. More...

#include <RobotAPI/libraries/armem/core/MemoryID.h>

Public Member Functions

void clearInstanceIndex ()
 
void clearTimestamp ()
 
std::vector< std::string > getAllItems (bool escapeDelimiters=false) const
 Get all levels as strings. More...
 
MemoryID getCoreSegmentID () const
 
MemoryID getEntityID () const
 
MemoryID getEntityInstanceID () const
 
MemoryID getEntitySnapshotID () const
 
std::vector< std::string > getItems (bool escapeDelimiters=false) const
 Get the levels from root to first not defined level (excluding). More...
 
std::string getLeafItem () const
 Get the lowest defined level (or empty string if there is none). More...
 
MemoryID getMemoryID () const
 
MemoryID getProviderSegmentID () const
 
bool hasCoreSegmentName () const
 
bool hasEntityName () const
 
bool hasGap () const
 Indicate whether this ID has a gap such as in 'Memory//MyProvider' (no core segment name). More...
 
bool hasInstanceIndex () const
 
bool hasMemoryName () const
 
bool hasProviderSegmentName () const
 
bool hasTimestamp () const
 
std::string instanceIndexStr () const
 Get the instance index as string. More...
 
bool isWellDefined () const
 Indicate whether this ID is well-defined. More...
 
 MemoryID ()
 Construct a default (empty) memory ID. More...
 
 MemoryID (const std::string &memoryName, const std::string &coreSegmentName, const std::string &providerSegmentName="", const std::string &entityName="", Time timestamp=Time::Invalid(), int instanceIndex=-1)
 
 MemoryID (const std::string &string)
 (Re-)Construct a memory ID from a string representation as returned by str(). More...
 
bool operator!= (const MemoryID &other) const
 
bool operator< (const MemoryID &rhs) const
 
bool operator<= (const MemoryID &rhs) const
 
bool operator== (const MemoryID &other) const
 
bool operator> (const MemoryID &rhs) const
 
bool operator>= (const MemoryID &rhs) const
 
MemoryID removeLeafItem () const
 
void setCoreSegmentID (const MemoryID &id)
 
void setEntityID (const MemoryID &id)
 
void setEntityInstanceID (const MemoryID &id)
 
void setEntitySnapshotID (const MemoryID &id)
 
void setMemoryID (const MemoryID &id)
 
void setProviderSegmentID (const MemoryID &id)
 
std::string str (bool escapeDelimiters=true) const
 Get a string representation of this memory ID. More...
 
std::string timestampStr () const
 Get the timestamp as string. More...
 
MemoryID withCoreSegmentName (const std::string &name) const
 
MemoryID withEntityName (const std::string &name) const
 
MemoryID withInstanceIndex (int index) const
 
MemoryID withMemoryName (const std::string &name) const
 
MemoryID withProviderSegmentName (const std::string &name) const
 
MemoryID withTimestamp (Time time) const
 

Static Public Member Functions

static MemoryID fromString (const std::string &string)
 Alias for constructor from string. More...
 
static int instanceIndexFromStr (const std::string &index)
 Reconstruct an instance index from a string as returned by instanceIndexStr(). More...
 
static Time timestampFromStr (const std::string &timestamp)
 Reconstruct a timestamp from a string as returned by timestampStr(). More...
 

Data Fields

std::string coreSegmentName = ""
 
std::string entityName = ""
 
int instanceIndex = -1
 
std::string memoryName = ""
 
std::string providerSegmentName = ""
 
Time timestamp = Time::Invalid()
 

Friends

std::ostream & operator<< (std::ostream &os, const MemoryID id)
 

Detailed Description

A memory ID.

A memory ID is an index into the hierarchical memory structure. It specifies the keys for the different levels, starting from the memory name and ending at the instance index.

A memory ID need not be complete, e.g. it may specify only the memory and core segment names (thus representing a core segment ID). A memory ID that fully identifies a level starting from the memory is called well-defined.

See also
isWellDefined()

Memory IDs can be encoded in strings using a delimiter:

  • Structure: "MemoryName/CoreSegmentName/ProviderSegmentName/EntityName/Timestamp/InstanceIndex"
  • Example: "Vision/RGBImages/Primesense/image/1245321323/0"
    See also
    str()
    If an ID does not specify the lower levels, these parts can be omitted. Thus, an entity ID could look like:
  • Structure: "MemoryName/CoreSegmentName/ProviderSegmentName/EntityName"
  • Example: "Vision/RGBImages/Primesense/image"

If a name contains a "/", it will be escaped:

  • Example: "Vision/RGBImages/Primesense/my\/entity\/with\/slashes"

Memory IDs may be not well-defined. This can occur e.g. when preparing an entity instance ID which is still pending the timestamp. It could look like (note the missing timestamp):

  • Example: "Vision/RGBImages/Primesense/image//0"

These IDs are still valid and can be handled (encoded as string etc.). However, some operations may not be well-defined for non-well-defined IDs (such as contains()).

Definition at line 48 of file MemoryID.h.

Constructor & Destructor Documentation

◆ MemoryID() [1/3]

MemoryID ( )

Construct a default (empty) memory ID.

Definition at line 20 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ MemoryID() [2/3]

MemoryID ( const std::string &  string)
explicit

(Re-)Construct a memory ID from a string representation as returned by str().

Definition at line 24 of file MemoryID.cpp.

+ Here is the call graph for this function:

◆ MemoryID() [3/3]

MemoryID ( const std::string &  memoryName,
const std::string &  coreSegmentName,
const std::string &  providerSegmentName = "",
const std::string &  entityName = "",
Time  timestamp = Time::Invalid(),
int  instanceIndex = -1 
)

Definition at line 84 of file MemoryID.cpp.

Member Function Documentation

◆ clearInstanceIndex()

void clearInstanceIndex ( )
inline

Definition at line 127 of file MemoryID.h.

◆ clearTimestamp()

void clearTimestamp ( )
inline

Definition at line 119 of file MemoryID.h.

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

◆ fromString()

MemoryID fromString ( const std::string &  string)
static

Alias for constructor from string.

Definition at line 153 of file MemoryID.cpp.

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

◆ getAllItems()

std::vector< std::string > getAllItems ( bool  escapeDelimiters = false) const

Get all levels as strings.

Definition at line 197 of file MemoryID.cpp.

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

◆ getCoreSegmentID()

MemoryID getCoreSegmentID ( ) const

Definition at line 214 of file MemoryID.cpp.

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

◆ getEntityID()

MemoryID getEntityID ( ) const

Definition at line 228 of file MemoryID.cpp.

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

◆ getEntityInstanceID()

MemoryID getEntityInstanceID ( ) const

Definition at line 242 of file MemoryID.cpp.

+ Here is the call graph for this function:

◆ getEntitySnapshotID()

MemoryID getEntitySnapshotID ( ) const

Definition at line 235 of file MemoryID.cpp.

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

◆ getItems()

std::vector< std::string > getItems ( bool  escapeDelimiters = false) const

Get the levels from root to first not defined level (excluding).

Definition at line 158 of file MemoryID.cpp.

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

◆ getLeafItem()

std::string getLeafItem ( ) const

Get the lowest defined level (or empty string if there is none).

Definition at line 116 of file MemoryID.cpp.

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

◆ getMemoryID()

MemoryID getMemoryID ( ) const

Definition at line 207 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ getProviderSegmentID()

MemoryID getProviderSegmentID ( ) const

Definition at line 221 of file MemoryID.cpp.

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

◆ hasCoreSegmentName()

bool hasCoreSegmentName ( ) const
inline

Definition at line 103 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasEntityName()

bool hasEntityName ( ) const
inline

Definition at line 111 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasGap()

bool hasGap ( ) const

Indicate whether this ID has a gap such as in 'Memory//MyProvider' (no core segment name).

Definition at line 129 of file MemoryID.cpp.

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

◆ hasInstanceIndex()

bool hasInstanceIndex ( ) const
inline

Definition at line 123 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasMemoryName()

bool hasMemoryName ( ) const
inline

Definition at line 99 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasProviderSegmentName()

bool hasProviderSegmentName ( ) const
inline

Definition at line 107 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasTimestamp()

bool hasTimestamp ( ) const
inline

Definition at line 115 of file MemoryID.h.

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

◆ instanceIndexFromStr()

int instanceIndexFromStr ( const std::string &  index)
static

Reconstruct an instance index from a string as returned by instanceIndexStr().

Definition at line 367 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ instanceIndexStr()

std::string instanceIndexStr ( ) const

Get the instance index as string.

Definition at line 357 of file MemoryID.cpp.

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

◆ isWellDefined()

bool isWellDefined ( ) const

Indicate whether this ID is well-defined.

A well-defined ID has no specified level after a non-specified level (i.e., no gaps).

Well-defined examples:

  • "" (empty, but well-defined)
  • "Memory" (a memory ID)
  • "Memory/Core" (a core segment ID)
  • "Memory/Core/Provider" (a provider segment ID)

Non-well-defined examples:

  • "Memory//Provider" (no core segment name)
  • "/Core" (no memory name)
  • "Mem/Core/Prov/entity//0" (no timestamp)
  • "///entity//0" (no memory, core segment and provider segment names)
Returns
True if *this is a well-defined memory ID.

Definition at line 147 of file MemoryID.cpp.

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

◆ operator!=()

bool operator!= ( const MemoryID other) const
inline

Definition at line 210 of file MemoryID.h.

◆ operator<()

bool operator< ( const MemoryID rhs) const

Definition at line 382 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ operator<=()

bool operator<= ( const MemoryID rhs) const
inline

Definition at line 220 of file MemoryID.h.

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const MemoryID other) const

Definition at line 372 of file MemoryID.cpp.

◆ operator>()

bool operator> ( const MemoryID rhs) const
inline

Definition at line 216 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ operator>=()

bool operator>= ( const MemoryID rhs) const
inline

Definition at line 224 of file MemoryID.h.

+ Here is the call graph for this function:

◆ removeLeafItem()

MemoryID removeLeafItem ( ) const

Definition at line 249 of file MemoryID.cpp.

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

◆ setCoreSegmentID()

void setCoreSegmentID ( const MemoryID id)

Definition at line 279 of file MemoryID.cpp.

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

◆ setEntityID()

void setEntityID ( const MemoryID id)

Definition at line 291 of file MemoryID.cpp.

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

◆ setEntityInstanceID()

void setEntityInstanceID ( const MemoryID id)

Definition at line 303 of file MemoryID.cpp.

+ Here is the call graph for this function:

◆ setEntitySnapshotID()

void setEntitySnapshotID ( const MemoryID id)

Definition at line 297 of file MemoryID.cpp.

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

◆ setMemoryID()

void setMemoryID ( const MemoryID id)

Definition at line 274 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ setProviderSegmentID()

void setProviderSegmentID ( const MemoryID id)

Definition at line 285 of file MemoryID.cpp.

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

◆ str()

std::string str ( bool  escapeDelimiters = true) const

Get a string representation of this memory ID.

Items are separated by a delimiter. If escapeDelimiter is true, delimiters occuring inside names are escaped with backward slashes. This allows to reconstruct the memory ID from the result of str() in these cases.

Parameters
escapeDelimiterIf true, escape delimiters inside names
Returns
A string representation of this MemoryID.

Definition at line 101 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ timestampFromStr()

Time timestampFromStr ( const std::string &  timestamp)
static

Reconstruct a timestamp from a string as returned by timestampStr().

Definition at line 362 of file MemoryID.cpp.

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

◆ timestampStr()

std::string timestampStr ( ) const

Get the timestamp as string.

Definition at line 352 of file MemoryID.cpp.

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

◆ withCoreSegmentName()

MemoryID withCoreSegmentName ( const std::string &  name) const

Definition at line 316 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withEntityName()

MemoryID withEntityName ( const std::string &  name) const

Definition at line 330 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withInstanceIndex()

MemoryID withInstanceIndex ( int  index) const

Definition at line 344 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withMemoryName()

MemoryID withMemoryName ( const std::string &  name) const

Definition at line 309 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withProviderSegmentName()

MemoryID withProviderSegmentName ( const std::string &  name) const

Definition at line 323 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withTimestamp()

MemoryID withTimestamp ( Time  time) const

Definition at line 337 of file MemoryID.cpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const MemoryID  id 
)
friend

Definition at line 453 of file MemoryID.cpp.

Field Documentation

◆ coreSegmentName

std::string coreSegmentName = ""

Definition at line 53 of file MemoryID.h.

◆ entityName

std::string entityName = ""

Definition at line 55 of file MemoryID.h.

◆ instanceIndex

int instanceIndex = -1

Definition at line 57 of file MemoryID.h.

◆ memoryName

std::string memoryName = ""

Definition at line 52 of file MemoryID.h.

◆ providerSegmentName

std::string providerSegmentName = ""

Definition at line 54 of file MemoryID.h.

◆ timestamp

Time timestamp = Time::Invalid()

Definition at line 56 of file MemoryID.h.


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