Aria  2.8.0
ArMapId Class Reference

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.
 
ArMapIdoperator= (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 &timestamp)
 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...
 

Detailed Description

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.

See also
ArMD5Calculator

Constructor & Destructor Documentation

◆ ArMapId()

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.

Parameters
sourceNamethe const char * name of the robot or server from which the map originated
fileNamethe const char * name of the map file
checksumthe unsigned char * buffer that contains the file checksum
checksumLengththe size_t length of the checksum buffer
sizethe long int number of bytes in the map file
timestampthe time_t last modified time of the map file
See also
ArMD5Calculator

Member Function Documentation

◆ create()

bool ArMapId::create ( const char *  fileName,
ArMapId mapIdOut 
)
static

Given a local file name, creates the map ID.

This method calculates the checksum of the specified file

Parameters
fileNamethe const char * name of the file for which to create the map ID
mapIdOuta pointer to the map ID to be filled in with the results
Returns
bool true if the file was found and the map ID created; false, otherwise.

◆ fromPacket()

bool ArMapId::fromPacket ( ArBasePacket packetIn,
ArMapId mapIdOut 
)
static

Extracts a map ID from the given network packet.

Parameters
packetInthe ArBasePacket from which to read the map ID
mapIdOuta pointer to the ArMapId to be filled in with the results
Returns
bool true if the map ID was successfully read from the given packet, false otherwise.
See also
toPacket for a description of the packet format

◆ getFileName()

const char * ArMapId::getFileName ( ) const

Returns the string name of the file.

TODO: Does this include path name??

◆ toPacket()

bool ArMapId::toPacket ( const ArMapId mapId,
ArBasePacket packetOut 
)
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
Parameters
mapIdthe ArMapId to be inserted into the packet
packetOutthe ArBasePacket * to be modified

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const ArMapId id1,
const ArMapId id2 
)
friend

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.

◆ operator==

bool operator== ( const ArMapId id1,
const ArMapId id2 
)
friend

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.


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