MemoryID Class Reference

A memory ID. More...

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

Public Member Functions

MemoryID cleanID () const
 
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 fromItems (const std::vector< std::string > &items)
 Constructor memory ID from items as returned by getItems(). More...
 
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...
 

Public Attributes

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 47 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 86 of file MemoryID.cpp.

Member Function Documentation

◆ cleanID()

MemoryID cleanID ( ) const

Definition at line 132 of file MemoryID.cpp.

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

◆ clearInstanceIndex()

void clearInstanceIndex ( )
inline

Definition at line 145 of file MemoryID.h.

◆ clearTimestamp()

void clearTimestamp ( )
inline

Definition at line 133 of file MemoryID.h.

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

◆ fromItems()

MemoryID fromItems ( const std::vector< std::string > &  items)
static

Constructor memory ID from items as returned by getItems().

Definition at line 189 of file MemoryID.cpp.

+ 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 183 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 268 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 289 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 305 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 321 of file MemoryID.cpp.

+ Here is the call graph for this function:

◆ getEntitySnapshotID()

MemoryID getEntitySnapshotID ( ) const

Definition at line 313 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 228 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 119 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 281 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ getProviderSegmentID()

MemoryID getProviderSegmentID ( ) const

Definition at line 297 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 109 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasEntityName()

bool hasEntityName ( ) const
inline

Definition at line 121 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 158 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 139 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasMemoryName()

bool hasMemoryName ( ) const
inline

Definition at line 103 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasProviderSegmentName()

bool hasProviderSegmentName ( ) const
inline

Definition at line 115 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ hasTimestamp()

bool hasTimestamp ( ) const
inline

Definition at line 127 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 462 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 450 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 177 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 229 of file MemoryID.h.

◆ operator<()

bool operator< ( const MemoryID rhs) const

Definition at line 477 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ operator<=()

bool operator<= ( const MemoryID rhs) const
inline

Definition at line 243 of file MemoryID.h.

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const MemoryID other) const

Definition at line 468 of file MemoryID.cpp.

◆ operator>()

bool operator> ( const MemoryID rhs) const
inline

Definition at line 237 of file MemoryID.h.

+ Here is the caller graph for this function:

◆ operator>=()

bool operator>= ( const MemoryID rhs) const
inline

Definition at line 249 of file MemoryID.h.

+ Here is the call graph for this function:

◆ removeLeafItem()

MemoryID removeLeafItem ( ) const

Definition at line 329 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 361 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 375 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 389 of file MemoryID.cpp.

+ Here is the call graph for this function:

◆ setEntitySnapshotID()

void setEntitySnapshotID ( const MemoryID id)

Definition at line 382 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 355 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ setProviderSegmentID()

void setProviderSegmentID ( const MemoryID id)

Definition at line 368 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 102 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 456 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 444 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 404 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withEntityName()

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

Definition at line 420 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withInstanceIndex()

MemoryID withInstanceIndex ( int  index) const

Definition at line 436 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withMemoryName()

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

Definition at line 396 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withProviderSegmentName()

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

Definition at line 412 of file MemoryID.cpp.

+ Here is the caller graph for this function:

◆ withTimestamp()

MemoryID withTimestamp ( Time  time) const

Definition at line 428 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 552 of file MemoryID.cpp.

Member Data Documentation

◆ coreSegmentName

std::string coreSegmentName = ""

Definition at line 51 of file MemoryID.h.

◆ entityName

std::string entityName = ""

Definition at line 53 of file MemoryID.h.

◆ instanceIndex

int instanceIndex = -1

Definition at line 55 of file MemoryID.h.

◆ memoryName

std::string memoryName = ""

Definition at line 50 of file MemoryID.h.

◆ providerSegmentName

std::string providerSegmentName = ""

Definition at line 52 of file MemoryID.h.

◆ timestamp

Time timestamp = Time::Invalid()

Definition at line 54 of file MemoryID.h.


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