|
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 ×tamp) |
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) |
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.
isWellDefined()
Memory IDs can be encoded in strings using a delimiter:
str()
If a name contains a "/", it will be escaped:
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):
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.
MemoryID | ( | ) |
Construct a default (empty) memory ID.
Definition at line 20 of file MemoryID.cpp.
|
explicit |
(Re-)Construct a memory ID from a string representation as returned by str()
.
Definition at line 24 of file MemoryID.cpp.
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.
MemoryID cleanID | ( | ) | const |
Definition at line 132 of file MemoryID.cpp.
|
inline |
Definition at line 145 of file MemoryID.h.
|
inline |
Definition at line 133 of file MemoryID.h.
|
static |
Constructor memory ID from items as returned by getItems().
Definition at line 189 of file MemoryID.cpp.
|
static |
Alias for constructor from string.
Definition at line 183 of file MemoryID.cpp.
std::vector< std::string > getAllItems | ( | bool | escapeDelimiters = false | ) | const |
Get all levels as strings.
Definition at line 268 of file MemoryID.cpp.
MemoryID getCoreSegmentID | ( | ) | const |
Definition at line 289 of file MemoryID.cpp.
MemoryID getEntityID | ( | ) | const |
Definition at line 305 of file MemoryID.cpp.
MemoryID getEntityInstanceID | ( | ) | const |
MemoryID getEntitySnapshotID | ( | ) | const |
Definition at line 313 of file MemoryID.cpp.
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.
std::string getLeafItem | ( | ) | const |
Get the lowest defined level (or empty string if there is none).
Definition at line 119 of file MemoryID.cpp.
MemoryID getMemoryID | ( | ) | const |
MemoryID getProviderSegmentID | ( | ) | const |
Definition at line 297 of file MemoryID.cpp.
|
inline |
|
inline |
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.
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 127 of file MemoryID.h.
|
static |
Reconstruct an instance index from a string as returned by instanceIndexStr()
.
Definition at line 462 of file MemoryID.cpp.
std::string instanceIndexStr | ( | ) | const |
Get the instance index as string.
Definition at line 450 of file MemoryID.cpp.
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:
Non-well-defined examples:
*this
is a well-defined memory ID. Definition at line 177 of file MemoryID.cpp.
|
inline |
Definition at line 229 of file MemoryID.h.
bool operator< | ( | const MemoryID & | rhs | ) | const |
|
inline |
bool operator== | ( | const MemoryID & | other | ) | const |
Definition at line 468 of file MemoryID.cpp.
|
inline |
|
inline |
MemoryID removeLeafItem | ( | ) | const |
Definition at line 329 of file MemoryID.cpp.
void setCoreSegmentID | ( | const MemoryID & | id | ) |
Definition at line 361 of file MemoryID.cpp.
void setEntityID | ( | const MemoryID & | id | ) |
Definition at line 375 of file MemoryID.cpp.
void setEntityInstanceID | ( | const MemoryID & | id | ) |
void setEntitySnapshotID | ( | const MemoryID & | id | ) |
Definition at line 382 of file MemoryID.cpp.
void setMemoryID | ( | const MemoryID & | id | ) |
void setProviderSegmentID | ( | const MemoryID & | id | ) |
Definition at line 368 of file MemoryID.cpp.
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.
escapeDelimiter | If true, escape delimiters inside names |
Definition at line 102 of file MemoryID.cpp.
|
static |
Reconstruct a timestamp from a string as returned by timestampStr()
.
Definition at line 456 of file MemoryID.cpp.
std::string timestampStr | ( | ) | const |
Get the timestamp as string.
Definition at line 444 of file MemoryID.cpp.
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 |
|
friend |
Definition at line 552 of file MemoryID.cpp.
std::string coreSegmentName = "" |
Definition at line 51 of file MemoryID.h.
std::string entityName = "" |
Definition at line 53 of file MemoryID.h.
int instanceIndex = -1 |
Definition at line 55 of file MemoryID.h.
std::string memoryName = "" |
Definition at line 50 of file MemoryID.h.
std::string providerSegmentName = "" |
Definition at line 52 of file MemoryID.h.
Time timestamp = Time::Invalid() |
Definition at line 54 of file MemoryID.h.