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

ArServerHandlerPopup.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 ARSERVERHANDLERPOPUP_H
00027 #define ARSERVERHANDLERPOPUP_H
00028 
00029 #include "Aria.h"
00030 #include "ArServerBase.h"
00031 
00032 
00033 class ArServerClient;
00034 
00035 class ArServerHandlerPopupInfo;
00036 
00038 
00042 class ArServerHandlerPopup
00043 {
00044 public:
00046   AREXPORT ArServerHandlerPopup(ArServerBase *server);
00048   AREXPORT virtual ~ArServerHandlerPopup();
00050   AREXPORT ArTypes::Byte4 createPopup(
00051           ArServerHandlerPopupInfo *popupInfo,
00052           ArFunctor2<ArTypes::Byte4, int> *callback = NULL);
00054   AREXPORT void closePopup(ArTypes::Byte4 id,
00055                             const char *closeMessage);
00057   AREXPORT void netPopupClicked(ArServerClient *client, 
00058                                 ArNetPacket *packet);
00060   AREXPORT void serverCycleCallback(void);
00061   enum PopupType { 
00062     NOICON = 0, 
00063     INFORMATION = 1, 
00064     WARNING = 2, 
00065     CRITICAL = 3, 
00066     QUESTION = 4 
00067   };
00068 protected:
00069   ArServerBase *myServer;
00070   class PopupData {
00071   public:
00073     PopupData(ArServerHandlerPopupInfo *popupInfo, 
00074               ArTypes::Byte4 id,
00075               ArFunctor2<ArTypes::Byte4, int> *callback);
00077     virtual ~PopupData();
00079     ArServerHandlerPopupInfo *myPopupInfo;
00081     ArFunctor2<ArTypes::Byte4, int> *myCallback;
00083     ArTime myStarted;
00085     ArTypes::Byte4 myID;
00086     
00087   };
00088   ArMutex myDataMutex;
00089   std::map<ArTypes::Byte4, PopupData *> myMap;
00090   ArTypes::Byte4 myLastID;
00091   ArTime myLastTimeCheck;
00092   ArFunctor2C<ArServerHandlerPopup, ArServerClient*, 
00093       ArNetPacket *> myNetPopupClickedCB;
00094   ArFunctorC<ArServerHandlerPopup> myServerCycleCB;
00095 };
00096 
00098 
00157 class ArServerHandlerPopupInfo
00158 {
00159 public:
00161   AREXPORT ArServerHandlerPopupInfo(
00162           const char *ignoreIdentifier, const char *title, 
00163           const char *message, ArServerHandlerPopup::PopupType popupType, 
00164           ArTypes::Byte defaultButtonNumber, 
00165           ArTypes::Byte escapeButtonNumber,  
00166           int timeoutInSeconds, const char *timeoutString,
00167           const char *button0Label, const char *button0Pressed, 
00168           const char *button1Label = "", const char *button1Pressed = "", 
00169           const char *button2Label = "", const char *button2Pressed = "");
00170 
00172   AREXPORT virtual ~ArServerHandlerPopupInfo();
00174   AREXPORT ArServerHandlerPopupInfo(const ArServerHandlerPopupInfo &popupInfo);
00176   AREXPORT ArServerHandlerPopupInfo &operator=(
00177           const ArServerHandlerPopupInfo &popupInfo);
00178 
00180   const char *getIgnoreIdentifier(void) { return myIgnoreIdentifier.c_str(); }
00182   const char *getTitle(void) { return myTitle.c_str(); }
00184   const char *getMessage(void) { return myMessage.c_str(); }
00186   ArServerHandlerPopup::PopupType getPopupType(void) { return myPopupType; }
00188   ArTypes::Byte getDefaultButtonNumber(void) { return myDefaultButtonNumber; }
00190   ArTypes::Byte getEscapeButtonNumber(void) { return myEscapeButtonNumber; }
00192   int getTimeout(void) { return myTimeout; }
00194   const char * getTimeoutString(void) 
00195     { return myTimeoutString.c_str(); }
00197   const char *getButton0Label(void) { return myButton0Label.c_str(); }
00199   const char *getButton0Pressed(void) { return myButton0Pressed.c_str(); }
00200 
00202   const char *getButton1Label(void) { return myButton1Label.c_str(); }
00204   const char *getButton1Pressed(void) { return myButton1Pressed.c_str(); }
00206   const char *getButton2Label(void) { return myButton2Label.c_str(); }
00208   const char *getButton2Pressed(void) { return myButton2Pressed.c_str(); }
00209 
00211   void setIgnoreIdentifier(const char *identifier) 
00212     { if (identifier != NULL) myIgnoreIdentifier = identifier; else myIgnoreIdentifier = ""; }
00214   void setTitle(const char *title) 
00215     { if (title != NULL) myTitle = title; else myTitle = ""; }
00217   void setMessage(const char *message) 
00218     { if (message != NULL) myMessage = message; else myMessage = ""; }
00220   void setPopupType(ArServerHandlerPopup::PopupType popupType) 
00221     { myPopupType = popupType; }
00223   void setDefaultButtonNumber(ArTypes::Byte defaultButtonNumber) 
00224     { myDefaultButtonNumber = defaultButtonNumber; }
00226   void setEscapeButtonNumber(ArTypes::Byte escapeButtonNumber) 
00227     { myEscapeButtonNumber = escapeButtonNumber; }
00229   void setTimeout(int timeoutInSeconds)
00230     { myTimeout = timeoutInSeconds; }
00232   void setTimeoutString(const char *timeoutString) 
00233     { if (timeoutString != NULL) myTimeoutString = timeoutString; else myTimeoutString = ""; }
00235   void setButton0Label(const char *label) 
00236     { if (label != NULL) myButton0Label = label; else myButton0Label = ""; }
00238   void setButton0Pressed(const char *pressed) 
00239     { if (pressed != NULL) myButton0Pressed = pressed; else myButton0Pressed = ""; }
00241   void setButton1Label(const char *label) 
00242     { if (label != NULL) myButton1Label = label; else myButton1Label = ""; }
00244   void setButton1Pressed(const char *pressed) 
00245     { if (pressed != NULL) myButton1Pressed = pressed; else myButton1Pressed = ""; }
00247   void setButton2Label(const char *label) 
00248     { if (label != NULL) myButton2Label = label; else myButton2Label = ""; }
00250   void setButton2Pressed(const char *pressed) 
00251     { if (pressed != NULL) myButton2Pressed = pressed; else myButton2Pressed = ""; }
00252 
00253 protected:
00254   std::string myIgnoreIdentifier;
00255   std::string myTitle;
00256   std::string myMessage;
00257   ArServerHandlerPopup::PopupType myPopupType;
00258   ArTypes::Byte myDefaultButtonNumber;
00259   ArTypes::Byte myEscapeButtonNumber;
00260   int myTimeout;
00261   std::string myTimeoutString;
00262   std::string myButton0Label;
00263   std::string myButton0Pressed;
00264   std::string myButton1Label;
00265   std::string myButton1Pressed;
00266   std::string myButton2Label;
00267   std::string myButton2Pressed;
00268 };
00269 
00270 #endif // ARSERVERHANDLERPOPUP_H

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