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

ArServerHandlerMap.h

Go to the documentation of this file.
00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARSERVERMAP_H
00027 #define ARSERVERMAP_H
00028 
00029 #include "Aria.h"
00030 #include "ArServerBase.h"
00031 #include "ArConfig.h"
00032 
00033 
00034 class ArServerClient;
00035 
00036 class ArMap;
00037 
00088 class ArServerHandlerMap
00089 {
00090 public:
00091   enum DataToSend { LINES = 1, POINTS = 2, BOTH = 3 };
00093   AREXPORT ArServerHandlerMap(ArServerBase *server, ArMap *arMap = NULL, 
00094                               DataToSend dataToSend = BOTH);
00096   AREXPORT virtual ~ArServerHandlerMap();
00098   AREXPORT bool loadMap(const char *mapFile);
00100   AREXPORT void useMap(ArMap *mapObj, bool takeOwnershipOfMap = false);
00102   AREXPORT ArMap *getMap(void);
00104   AREXPORT void serverGetMapName(ArServerClient *client,
00105                                  ArNetPacket *packet);
00107   AREXPORT void serverGetMap(ArServerClient *client,
00108                              ArNetPacket *packet);
00110   AREXPORT void serverGetMapBinary(ArServerClient *client,
00111                                    ArNetPacket *packet);
00113   AREXPORT void serverGetGoals(ArServerClient *client,
00114                                ArNetPacket *packet);
00116   AREXPORT void setDataToSend(DataToSend dataToSend) 
00117     { myDataToSend = dataToSend; }
00119   DataToSend getDataToSend(void) { return myDataToSend; }
00120 protected:
00121   AREXPORT bool processFile(void);
00122   AREXPORT void mapChanged(void);
00123   // internal function that is used to toss the map to the client
00124   AREXPORT void writeMapToClient(const char *line, ArServerClient *client);
00125  
00126 
00127   AREXPORT void writePointsToClient(int pointCount,
00128                                     std::vector<ArPose> *points,
00129                                     ArServerClient *client);
00130 
00131   AREXPORT void writeLinesToClient(int lineCount,
00132                                     std::vector<ArLineSegment> *points,
00133                                     ArServerClient *client);
00134 
00135   ArServerBase *myServer;
00136   bool myOwnMap;
00137   DataToSend myDataToSend;
00138   ArMap *myMap;
00139   std::string myMapName;
00140   ArServerHandlerMap *myServerHandlerMap;
00141   bool myAlreadyLoaded;
00142   char myMapFileName[512];
00143   char myLastMapFile[1024];
00144   struct stat myLastMapFileStat;
00145   ArFunctor2C<ArServerHandlerMap, 
00146       ArServerClient *, ArNetPacket *> myGetMapNameCB;
00147   ArFunctor2C<ArServerHandlerMap, 
00148       ArServerClient *, ArNetPacket *> myGetMapCB;
00149   ArFunctor2C<ArServerHandlerMap, 
00150       ArServerClient *, ArNetPacket *> myGetMapBinaryCB;
00151   ArFunctor2C<ArServerHandlerMap, 
00152       ArServerClient *, ArNetPacket *> myGetGoalsCB;
00153   ArRetFunctorC<bool, ArServerHandlerMap> myProcessFileCB;
00154   ArFunctorC<ArServerHandlerMap> myMapChangedCB;
00155 };
00156 
00157 #endif
00158 

Generated on Tue Feb 20 10:51:50 2007 for ArNetworking by  doxygen 1.4.0