Aria
2.8.0
|
Enapsulates the data used to uniquely identify an Aria map. More...
#include <ArMapUtils.h>
Public Member Functions | |
ArMapId () | |
Default contructor creates a null map ID. | |
ArMapId (const char *sourceName, const char *fileName, const unsigned char *checksum, size_t checksumLength, long int size, const time_t timestamp) | |
Creates a map ID with the given attributes. More... | |
ArMapId (const ArMapId &other) | |
Copy constructor. | |
void | clear () |
Clears this map ID, i.e. sets it to null. | |
const unsigned char * | getChecksum () const |
Returns a pointer to the buffer that contains the checksum. | |
size_t | getChecksumLength () const |
Returns the length of the checksum. | |
const char * | getDisplayChecksum () const |
Returns the checksum in a human readable string format. | |
const char * | getFileName () const |
Returns the string name of the file. More... | |
long int | getSize () const |
Returns the number of bytes in the map file. | |
const char * | getSourceName () const |
Returns the string name of the originating robot or server. | |
time_t | getTimestamp () const |
Returns the last modified time of the file. | |
bool | isNull () const |
Returns whether this map ID is null. | |
bool | isSameFile (const ArMapId &other) const |
TODO Think that this is the same as operator==. | |
bool | isValidTimestamp () const |
Returns true if the timestamp is valid; false if it's a special 'not-set' indicator. | |
bool | isVersionOfSameFile (const ArMapId &other) const |
Returns whether the source and file names are identical. | |
void | log (const char *prefix) const |
Writes the map ID to the output log file, with the specified prefix /header. | |
ArMapId & | operator= (const ArMapId &other) |
Assignment operator. | |
void | setChecksum (const unsigned char *checksum, size_t checksumLen) |
Sets the checksum of the map file. | |
void | setFileName (const char *fileName) |
Sets the map file name. | |
void | setSize (long int size) |
Sets the number of bytes in the map file. | |
void | setSourceName (const char *sourceName) |
Sets the name of the source robot or server that originated the map file. | |
void | setTimestamp (const time_t ×tamp) |
Sets the last modified time of the map file. | |
~ArMapId () | |
Destructor. | |
Static Public Member Functions | |
static bool | create (const char *fileName, ArMapId *mapIdOut) |
Given a local file name, creates the map ID. More... | |
static bool | fromPacket (ArBasePacket *packetIn, ArMapId *mapIdOut) |
Extracts a map ID from the given network packet. More... | |
static bool | toPacket (const ArMapId &mapId, ArBasePacket *packetOut) |
Inserts the given map ID into a network packet. More... | |
Protected Attributes | |
unsigned char * | myChecksum |
Buffer that contains the checksum of the map file. | |
size_t | myChecksumLength |
Length of the buffer that contains the checksum of the map file. | |
char * | myDisplayChecksum |
Buffer that contains the checksum in human readable format. | |
size_t | myDisplayChecksumLength |
Length of the displayable checksum buffer. | |
std::string | myFileName |
Name of the map file. | |
long int | mySize |
Number of bytes in the map file. | |
std::string | mySourceName |
Name of the source robot or server from which the map file originated. | |
time_t | myTimestamp |
Last modified time of the map file. | |
Friends | |
bool | operator!= (const ArMapId &id1, const ArMapId &id2) |
Returns whether the two map IDs are not equal. More... | |
bool | operator== (const ArMapId &id1, const ArMapId &id2) |
Returns whether the two map IDs are equivalent. More... | |
Enapsulates the data used to uniquely identify an Aria map.
ArMapId is a small helper class that contains all of the information needed to uniquely identify an Aria map. In addition to the standard file attributes (such as filename, size, and timestamps), it contains the name of the originating source robot or server. It also contains the checksum of the file contents. This checksum is currently calculated by the ArMD5Calculator class. All of the data should allow one to determine whether two map files are the same with a reasonable degree of certainty.
The ArMapId class is not thread-safe.
ArMapId::ArMapId | ( | const char * | sourceName, |
const char * | fileName, | ||
const unsigned char * | checksum, | ||
size_t | checksumLength, | ||
long int | size, | ||
const time_t | timestamp | ||
) |
Creates a map ID with the given attributes.
sourceName | the const char * name of the robot or server from which the map originated |
fileName | the const char * name of the map file |
checksum | the unsigned char * buffer that contains the file checksum |
checksumLength | the size_t length of the checksum buffer |
size | the long int number of bytes in the map file |
timestamp | the time_t last modified time of the map file |
|
static |
Given a local file name, creates the map ID.
This method calculates the checksum of the specified file
fileName | the const char * name of the file for which to create the map ID |
mapIdOut | a pointer to the map ID to be filled in with the results |
|
static |
Extracts a map ID from the given network packet.
packetIn | the ArBasePacket from which to read the map ID |
mapIdOut | a pointer to the ArMapId to be filled in with the results |
const char * ArMapId::getFileName | ( | ) | const |
Returns the string name of the file.
TODO: Does this include path name??
|
static |
Inserts the given map ID into a network packet.
The format of the map ID in the network packet is as follows:
string: source robot or server name string: map file name uByte4: number of bytes in the checksum data : checksum, included only if the number of bytes in the checksum is greater than 0 uByte4: file size byte4 : file last modified time
mapId | the ArMapId to be inserted into the packet |
packetOut | the ArBasePacket * to be modified |
Returns whether the two map IDs are not equal.
Note that if either map ID specifies a NULL timestamp, then the timestamp will not be used for comparison purposes.
Returns whether the two map IDs are equivalent.
Note that if either map ID specifies a NULL timestamp, then the timestamp will not be used for comparison purposes.