Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

ArServerHandlerMap Class Reference

Service providing the contents of a map file to the client. More...

#include <ArServerHandlerMap.h>

List of all members.

Public Types

enum  DataToSend { LINES = 1, POINTS = 2, BOTH = 3 }

Public Member Functions

 ArServerHandlerMap (ArServerBase *server, ArMap *arMap=NULL, DataToSend dataToSend=BOTH)
 Constructor.
DataToSend getDataToSend (void)
 Gets which kind of data we send.
ArMapgetMap (void)
 Gets the map object this is using.
bool loadMap (const char *mapFile)
 Loads the map from a file.
void serverGetGoals (ArServerClient *client, ArNetPacket *packet)
 The command that'll get the goals.
void serverGetMap (ArServerClient *client, ArNetPacket *packet)
 The command that'll get the map itself.
void serverGetMapBinary (ArServerClient *client, ArNetPacket *packet)
 The command that gets the map, with the data in binary format for improved performance.
void serverGetMapName (ArServerClient *client, ArNetPacket *packet)
 The command that gets the map name.
void setDataToSend (DataToSend dataToSend)
 Sets which kind of data we send.
void useMap (ArMap *mapObj, bool takeOwnershipOfMap=false)
 Uses a map already loaded.
virtual ~ArServerHandlerMap ()
 Destructor.

Protected Member Functions

void mapChanged (void)
bool processFile (void)
void writeLinesToClient (int lineCount, std::vector< ArLineSegment > *points, ArServerClient *client)
void writeMapToClient (const char *line, ArServerClient *client)
void writePointsToClient (int pointCount, std::vector< ArPose > *points, ArServerClient *client)

Protected Attributes

bool myAlreadyLoaded
DataToSend myDataToSend
ArFunctor2C< ArServerHandlerMap,
ArServerClient *, ArNetPacket * > 
myGetGoalsCB
ArFunctor2C< ArServerHandlerMap,
ArServerClient *, ArNetPacket * > 
myGetMapBinaryCB
ArFunctor2C< ArServerHandlerMap,
ArServerClient *, ArNetPacket * > 
myGetMapCB
ArFunctor2C< ArServerHandlerMap,
ArServerClient *, ArNetPacket * > 
myGetMapNameCB
char myLastMapFile [1024]
stat myLastMapFileStat
ArMapmyMap
ArFunctorC< ArServerHandlerMapmyMapChangedCB
char myMapFileName [512]
std::string myMapName
bool myOwnMap
ArRetFunctorC< bool, ArServerHandlerMapmyProcessFileCB
ArServerBasemyServer
ArServerHandlerMapmyServerHandlerMap


Detailed Description

Service providing the contents of a map file to the client.

A map can be provided from an ArMap object, or else the filename can be given in the global ArConfig object (see Aria::getConfig()) as "Map" in the "Files" section. This handler can also be configured to only send "point" data, "line" data, or both kinds of data from the map.

This service accepts the following data requests:

The following data types will also be broadcast to all clients to indicate certain events:

The getMapName request replies with a packet containing a NULL-terminated string containing the filename of the map, or an empty string ("") if there is no map.

The getMap request replies with a packet containing the map as it appears in the map file (see the documentation for ArMap for the file format).

The getGoals request replies with a series of NULL-terminated strings containing the names of the Goal objects in the map.

The getMapBinary request replies with the map headers and objects list (see ArMap for map file format) as text, but supplies point "DATA" and/or "LINES" as an undelimited sequence of 2-byte integers. (In the case of point data, each pair of integers is a point; for lines, each sequence of four integers defines a line). This binary representation of data is more compact than the ASCII text representation.

The mapUpdated packet is sent to all connected clients whenever a new map is loaded or the map is changed. The packet contains no data; the new map can be downloaded using one of the above requests.

The goalsUpdated packet is sent to all connected clients whenever the list of Goal objects changes in the map or a new map is loaded. The packet contains no data; the new list of goals can be downloaded using getGoals, or by downloading the entire map.

Definition at line 88 of file ArServerHandlerMap.h.


Member Enumeration Documentation

enum ArServerHandlerMap::DataToSend
 

Enumeration values:
LINES 
POINTS 
BOTH 

Definition at line 91 of file ArServerHandlerMap.h.


Constructor & Destructor Documentation

ArServerHandlerMap::ArServerHandlerMap ArServerBase server,
ArMap arMap = NULL,
DataToSend  dataToSend = BOTH
 

Constructor.

Parameters:
server the server to add our data too
arMap If this points to a map file then this will simply serve up that map file and add in a map changed cb for that map, otherwise it'll operate via the Aria::getConfig.
dataToSend Which data to send, just the lines, the points, or both

Definition at line 45 of file ArServerHandlerMap.cpp.

References ArServerBase::addData(), ArMap::addMapChangedCB(), ArConfig::addParam(), ArConfig::addProcessFileCB(), Aria::getConfig(), ArMap::getFileName(), myAlreadyLoaded, myGetGoalsCB, myGetMapBinaryCB, myGetMapCB, myGetMapNameCB, myMap, myMapChangedCB, myMapFileName, myOwnMap, myProcessFileCB, myServer, setDataToSend(), ArFunctor::setName(), and ArConfig::setSectionComment().

ArServerHandlerMap::~ArServerHandlerMap  )  [virtual]
 

Destructor.

Definition at line 110 of file ArServerHandlerMap.cpp.


Member Function Documentation

DataToSend ArServerHandlerMap::getDataToSend void   )  [inline]
 

Gets which kind of data we send.

Definition at line 119 of file ArServerHandlerMap.h.

References myDataToSend.

ArMap * ArServerHandlerMap::getMap void   ) 
 

Gets the map object this is using.

Definition at line 154 of file ArServerHandlerMap.cpp.

References myMap.

bool ArServerHandlerMap::loadMap const char *  mapFile  ) 
 

Loads the map from a file.

Definition at line 115 of file ArServerHandlerMap.cpp.

References ArServerBase::broadcastPacketTcp(), myMap, myMapName, myOwnMap, myServer, and ArMap::readFile().

Referenced by processFile().

void ArServerHandlerMap::mapChanged void   )  [protected]
 

Definition at line 511 of file ArServerHandlerMap.cpp.

References ArServerBase::broadcastPacketTcp(), ArMap::getFileName(), myMap, myMapFileName, and myServer.

bool ArServerHandlerMap::processFile void   )  [protected]
 

For internal use only.

Definition at line 520 of file ArServerHandlerMap.cpp.

References loadMap(), ArLog::log(), myAlreadyLoaded, myLastMapFile, myLastMapFileStat, and myMapFileName.

void ArServerHandlerMap::serverGetGoals ArServerClient client,
ArNetPacket packet
 

The command that'll get the goals.

For internal use only.

Definition at line 484 of file ArServerHandlerMap.cpp.

References client, ArMap::getMapObjects(), ArMapObject::getName(), ArMapObject::getType(), myMap, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf().

void ArServerHandlerMap::serverGetMap ArServerClient client,
ArNetPacket packet
 

The command that'll get the map itself.

For internal use only.

Definition at line 376 of file ArServerHandlerMap.cpp.

References client, ArMap::lock(), ArLog::log(), myMap, ArClientBase::sendPacketTcp(), ArMap::unlock(), writeMapToClient(), and ArMap::writeToFunctor().

void ArServerHandlerMap::serverGetMapBinary ArServerClient client,
ArNetPacket packet
 

The command that gets the map, with the data in binary format for improved performance.

Definition at line 410 of file ArServerHandlerMap.cpp.

References BOTH, client, ArMap::getLines(), LINES, ArMap::lock(), ArLog::log(), myDataToSend, myMap, POINTS, ArClientBase::sendPacketTcp(), ArMap::unlock(), writeLinesToClient(), ArMap::writeLinesToFunctor(), writeMapToClient(), ArMap::writeObjectsToFunctor(), writePointsToClient(), and ArMap::writePointsToFunctor().

void ArServerHandlerMap::serverGetMapName ArServerClient client,
ArNetPacket packet
 

The command that gets the map name.

For internal use only.

Definition at line 160 of file ArServerHandlerMap.cpp.

References client, ArMap::getFileName(), myMap, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf().

void ArServerHandlerMap::setDataToSend DataToSend  dataToSend  )  [inline]
 

Sets which kind of data we send.

Definition at line 116 of file ArServerHandlerMap.h.

References myDataToSend.

Referenced by ArServerHandlerMap().

void ArServerHandlerMap::useMap ArMap mapObj,
bool  takeOwnershipOfMap = false
 

Uses a map already loaded.

Definition at line 137 of file ArServerHandlerMap.cpp.

References ArServerBase::broadcastPacketTcp(), ArMap::getFileName(), myMap, myMapName, myOwnMap, and myServer.

void ArServerHandlerMap::writeLinesToClient int  lineCount,
std::vector< ArLineSegment > *  lines,
ArServerClient client
[protected]
 

For internal use only.

Definition at line 278 of file ArServerHandlerMap.cpp.

References ArBasePacket::byte4ToBuf(), client, ArNetPacket::empty(), ArLog::log(), and ArClientBase::sendPacketTcp().

Referenced by serverGetMapBinary().

void ArServerHandlerMap::writeMapToClient const char *  line,
ArServerClient client
[protected]
 

For internal use only.

Definition at line 177 of file ArServerHandlerMap.cpp.

References client, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf().

Referenced by serverGetMap(), and serverGetMapBinary().

void ArServerHandlerMap::writePointsToClient int  pointCount,
std::vector< ArPose > *  points,
ArServerClient client
[protected]
 

For internal use only.

Definition at line 186 of file ArServerHandlerMap.cpp.

References ArBasePacket::byte4ToBuf(), client, ArNetPacket::empty(), ArLog::log(), and ArClientBase::sendPacketTcp().

Referenced by serverGetMapBinary().


Member Data Documentation

bool ArServerHandlerMap::myAlreadyLoaded [protected]
 

Definition at line 141 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap(), and processFile().

DataToSend ArServerHandlerMap::myDataToSend [protected]
 

Definition at line 137 of file ArServerHandlerMap.h.

Referenced by getDataToSend(), serverGetMapBinary(), and setDataToSend().

ArFunctor2C<ArServerHandlerMap, ArServerClient *, ArNetPacket *> ArServerHandlerMap::myGetGoalsCB [protected]
 

Definition at line 152 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap().

ArFunctor2C<ArServerHandlerMap, ArServerClient *, ArNetPacket *> ArServerHandlerMap::myGetMapBinaryCB [protected]
 

Definition at line 150 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap().

ArFunctor2C<ArServerHandlerMap, ArServerClient *, ArNetPacket *> ArServerHandlerMap::myGetMapCB [protected]
 

Definition at line 148 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap().

ArFunctor2C<ArServerHandlerMap, ArServerClient *, ArNetPacket *> ArServerHandlerMap::myGetMapNameCB [protected]
 

Definition at line 146 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap().

char ArServerHandlerMap::myLastMapFile[1024] [protected]
 

Definition at line 143 of file ArServerHandlerMap.h.

Referenced by processFile().

struct stat ArServerHandlerMap::myLastMapFileStat [protected]
 

Definition at line 144 of file ArServerHandlerMap.h.

Referenced by processFile().

ArMap* ArServerHandlerMap::myMap [protected]
 

Definition at line 138 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap(), getMap(), loadMap(), mapChanged(), serverGetGoals(), serverGetMap(), serverGetMapBinary(), serverGetMapName(), and useMap().

ArFunctorC<ArServerHandlerMap> ArServerHandlerMap::myMapChangedCB [protected]
 

Definition at line 154 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap().

char ArServerHandlerMap::myMapFileName[512] [protected]
 

Definition at line 142 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap(), mapChanged(), and processFile().

std::string ArServerHandlerMap::myMapName [protected]
 

Definition at line 139 of file ArServerHandlerMap.h.

Referenced by loadMap(), and useMap().

bool ArServerHandlerMap::myOwnMap [protected]
 

Definition at line 136 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap(), loadMap(), and useMap().

ArRetFunctorC<bool, ArServerHandlerMap> ArServerHandlerMap::myProcessFileCB [protected]
 

Definition at line 153 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap().

ArServerBase* ArServerHandlerMap::myServer [protected]
 

Definition at line 135 of file ArServerHandlerMap.h.

Referenced by ArServerHandlerMap(), loadMap(), mapChanged(), and useMap().

ArServerHandlerMap* ArServerHandlerMap::myServerHandlerMap [protected]
 

Definition at line 140 of file ArServerHandlerMap.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 20 10:51:51 2007 for ArNetworking by  doxygen 1.4.0