ArMapId Class Reference

#include <ArMapUtils.h>

List of all members.


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


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


Constructor & Destructor Documentation

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:
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
See also:
ArMD5Calculator


Member Function Documentation

static 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:
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
Returns:
bool true if the file was found and the map ID created; false, otherwise.

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

Extracts a map ID from the given network packet.

Parameters:
packetIn the ArBasePacket from which to read the map ID
mapIdOut a 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

const char* ArMapId::getFileName (  )  const

Returns the string name of the file.

TODO: Does this include path name??

static 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:
mapId the ArMapId to be inserted into the packet
packetOut the ArBasePacket * to be modified


Friends And Related Function Documentation

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.

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 file:
Generated on Thu Aug 6 09:39:36 2009 for Aria by  doxygen 1.5.1