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.
 
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).
 
std::string getLeafItem () const
 Get the lowest defined level (or empty string if there is none).
 
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).
 
bool hasInstanceIndex () const
 
bool hasMemoryName () const
 
bool hasProviderSegmentName () const
 
bool hasTimestamp () const
 
std::string instanceIndexStr () const
 Get the instance index as string.
 
bool isWellDefined () const
 Indicate whether this ID is well-defined.
 
 MemoryID ()
 Construct a default (empty) memory ID.
 
 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().
 
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.
 
std::string timestampStr () const
 Get the timestamp as string.
 
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().
 
static MemoryID fromString (const std::string &string)
 Alias for constructor from string.
 
static int instanceIndexFromStr (const std::string &index)
 Reconstruct an instance index from a string as returned by instanceIndexStr().
 
static Time timestampFromStr (const std::string &timestamp)
 Reconstruct a timestamp from a string as returned by timestampStr().
 

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()).

Constructor & Destructor Documentation

◆ MemoryID() [1/3]

MemoryID ( )

Construct a default (empty) memory ID.

◆ MemoryID() [2/3]

MemoryID ( const std::string & string)
explicit

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

◆ 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 )

Member Function Documentation

◆ cleanID()

MemoryID cleanID ( ) const

◆ clearInstanceIndex()

void clearInstanceIndex ( )
inline

◆ clearTimestamp()

void clearTimestamp ( )
inline

◆ fromItems()

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

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

◆ fromString()

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

Alias for constructor from string.

◆ getAllItems()

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

Get all levels as strings.

◆ getCoreSegmentID()

MemoryID getCoreSegmentID ( ) const

◆ getEntityID()

MemoryID getEntityID ( ) const

◆ getEntityInstanceID()

MemoryID getEntityInstanceID ( ) const

◆ getEntitySnapshotID()

MemoryID getEntitySnapshotID ( ) const

◆ getItems()

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

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

◆ getLeafItem()

std::string getLeafItem ( ) const

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

◆ getMemoryID()

MemoryID getMemoryID ( ) const

◆ getProviderSegmentID()

MemoryID getProviderSegmentID ( ) const

◆ hasCoreSegmentName()

bool hasCoreSegmentName ( ) const
inline

◆ hasEntityName()

bool hasEntityName ( ) const
inline

◆ hasGap()

bool hasGap ( ) const

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

◆ hasInstanceIndex()

bool hasInstanceIndex ( ) const
inline

◆ hasMemoryName()

bool hasMemoryName ( ) const
inline

◆ hasProviderSegmentName()

bool hasProviderSegmentName ( ) const
inline

◆ hasTimestamp()

bool hasTimestamp ( ) const
inline

◆ instanceIndexFromStr()

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

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

◆ instanceIndexStr()

std::string instanceIndexStr ( ) const

Get the instance index as string.

◆ 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.

◆ operator!=()

bool operator!= ( const MemoryID & other) const
inline

◆ operator<()

bool operator< ( const MemoryID & rhs) const

◆ operator<=()

bool operator<= ( const MemoryID & rhs) const
inline

◆ operator==()

bool operator== ( const MemoryID & other) const

◆ operator>()

bool operator> ( const MemoryID & rhs) const
inline

◆ operator>=()

bool operator>= ( const MemoryID & rhs) const
inline

◆ removeLeafItem()

MemoryID removeLeafItem ( ) const

◆ setCoreSegmentID()

void setCoreSegmentID ( const MemoryID & id)

◆ setEntityID()

void setEntityID ( const MemoryID & id)

◆ setEntityInstanceID()

void setEntityInstanceID ( const MemoryID & id)

◆ setEntitySnapshotID()

void setEntitySnapshotID ( const MemoryID & id)

◆ setMemoryID()

void setMemoryID ( const MemoryID & id)

◆ setProviderSegmentID()

void setProviderSegmentID ( const MemoryID & id)

◆ 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.

◆ timestampFromStr()

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

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

◆ timestampStr()

std::string timestampStr ( ) const

Get the timestamp as string.

◆ withCoreSegmentName()

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

◆ withEntityName()

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

◆ withInstanceIndex()

MemoryID withInstanceIndex ( int index) const

◆ withMemoryName()

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

◆ withProviderSegmentName()

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

◆ withTimestamp()

MemoryID withTimestamp ( Time time) const

Friends And Related Symbol Documentation

◆ operator<<

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

Member Data Documentation

◆ coreSegmentName

std::string coreSegmentName = ""

◆ entityName

std::string entityName = ""

◆ instanceIndex

int instanceIndex = -1

◆ memoryName

std::string memoryName = ""

◆ providerSegmentName

std::string providerSegmentName = ""

◆ timestamp

Time timestamp = Time::Invalid()

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