#include <ArMapUtils.h>
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.
Public Member Functions | |
ArMapId (const ArMapId &other) | |
Copy constructor. | |
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. | |
ArMapId () | |
Default contructor creates a null map ID. | |
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. | |
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 | 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. | |
static bool | fromPacket (ArBasePacket *packetIn, ArMapId *mapIdOut) |
Extracts a map ID from the given network packet. | |
static bool | toPacket (const ArMapId &mapId, ArBasePacket *packetOut) |
Inserts the given map ID into a network packet. | |
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. | |
bool | operator== (const ArMapId &id1, const ArMapId &id2) |
Returns whether the two map IDs are equivalent. |
|
Creates a map ID with the given attributes.
|
|
Given a local file name, creates the map ID. This method calculates the checksum of the specified file
|
|
Extracts a map ID from the given network packet.
|
|
Returns the string name of the file. TODO: Does this include path name?? |
|
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
|
|
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. |