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

ArClientHandlerConfig.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 ARCLIENTCONFIGHANDLER_H
00027 #define ARCLIENTCONFIGHANDLER_H
00028 
00029 #include "Aria.h"
00030 #include "ArClientBase.h"
00031 
00033 
00048 class ArClientHandlerConfig
00049 {
00050 public:
00052   AREXPORT ArClientHandlerConfig(ArClientBase *client,
00053                                                          bool ignoreBounds = false,
00054                                  const char *robotName = NULL);
00056   AREXPORT virtual ~ArClientHandlerConfig(void);
00057 
00059   AREXPORT void requestConfigFromServer(void);
00061   AREXPORT void reloadConfigOnServer(void);
00062 
00064   AREXPORT ArConfig getConfigCopy(void);
00065 
00067   AREXPORT void addGotConfigCB(ArFunctor *functor, 
00068                                ArListPos::Pos position = ArListPos::LAST);
00070   AREXPORT void remGotConfigCB(ArFunctor *functor);
00072   AREXPORT void addSaveConfigSucceededCB(ArFunctor *functor, 
00073                            ArListPos::Pos position = ArListPos::LAST);
00075   AREXPORT void remSaveConfigSucceededCB(ArFunctor *functor);
00077   AREXPORT void addSaveConfigFailedCB(ArFunctor1<const char *> *functor, 
00078                            ArListPos::Pos position = ArListPos::LAST);
00080   AREXPORT void remSaveConfigFailedCB(ArFunctor1<const char *> *functor);
00081 
00083   AREXPORT bool haveGottenConfig(void);
00085   AREXPORT void saveConfigToServer(void);
00087   AREXPORT void saveConfigToServer(
00088           ArConfig *config, 
00089           const std::set<std::string, 
00090           ArStrCaseCmpOp> *ignoreTheseSections = NULL);
00091 
00093   AREXPORT bool haveRequestedDefaults(void);
00095   AREXPORT bool haveGottenDefaults(void);
00096 
00098   AREXPORT bool canRequestDefaults(void);
00099 
00100   AREXPORT bool requestDefaultConfigFromServer(void);
00101   AREXPORT ArConfig *getDefaultConfig();
00102 
00104   AREXPORT bool requestConfigDefaults(void);
00106   AREXPORT bool requestSectionDefaults(const char *section);
00107   
00108 
00110   AREXPORT void addGotConfigDefaultsCB(ArFunctor *functor, 
00111                            ArListPos::Pos position = ArListPos::LAST);
00113   AREXPORT void remGotConfigDefaultsCB(ArFunctor *functor);
00114 
00116   AREXPORT ArConfig *getConfig(void);
00118   AREXPORT int lock(void);
00120   AREXPORT int tryLock(void);
00122   AREXPORT int unlock(void);
00123 
00125   AREXPORT void handleGetConfigBySections(ArNetPacket *packet);
00126 
00128   AREXPORT void handleGetConfigSectionFlags(ArNetPacket *packet);
00129 
00131   AREXPORT void handleGetConfig(ArNetPacket *packet);
00132 
00134   AREXPORT void handleSetConfig(ArNetPacket *packet);
00136   AREXPORT void handleGetConfigDefaults(ArNetPacket *packet);
00137 
00138 protected:
00139 
00140   AREXPORT void handleGetConfigData(ArNetPacket *packet,
00141                                     bool isMultiplePackets);
00142 
00143 
00144 protected:
00145 
00146   std::string myRobotName;
00147   std::string myLogPrefix;
00148 
00149   std::list<ArFunctor *> myGotConfigCBList;
00150   std::list<ArFunctor *> mySaveConfigSucceededCBList;
00151   std::list<ArFunctor1<const char *> *> mySaveConfigFailedCBList;
00152   std::list<ArFunctor *> myGotConfigDefaultsCBList;
00153   ArClientBase *myClient;
00154   ArConfig myConfig;
00155   ArConfig *myDefaultConfig;
00156   ArMutex myDataMutex;
00157   ArMutex myCallbackMutex;
00158   bool myHaveGottenConfig;
00159   bool myHaveRequestedDefaults;
00160   bool myHaveGottenDefaults;
00161   bool myHaveRequestedDefaultCopy;
00162 
00163   ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleGetConfigBySectionsCB;
00164   ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleGetConfigCB;
00165   ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> myHandleSetConfigCB;
00166   ArFunctor1C<ArClientHandlerConfig, 
00167       ArNetPacket *> myHandleGetConfigDefaultsCB;
00168   ArFunctor1C<ArClientHandlerConfig, 
00169       ArNetPacket *> myHandleGetDefaultConfigCB;
00170   ArFunctor1C<ArClientHandlerConfig, 
00171               ArNetPacket *> myHandleGetConfigSectionFlagsCB;
00172 };
00173 
00174 #endif

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