00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ARIAINTERNAL_H
00027 #define ARIAINTERNAL_H
00028
00029
00030 #include "ArMutex.h"
00031 #include "ArFunctor.h"
00032 #include "ArConfig.h"
00033
00034 #ifndef ARINTERFACE
00035 #include "ArStringInfoGroup.h"
00036 class ArRobot;
00037 class ArRobotJoyHandler;
00038 #endif // ARINTERFACE
00039
00040 class ArKeyHandler;
00041 class ArJoyHandler;
00042
00043
00045 class Aria
00046 {
00047 public:
00048
00049 typedef enum {
00050 SIGHANDLE_SINGLE,
00051 SIGHANDLE_THREAD,
00052 SIGHANDLE_NONE
00053 } SigHandleMethod;
00054
00056 AREXPORT static void init(SigHandleMethod method = SIGHANDLE_THREAD,
00057 bool initSockets = true,
00058 bool sigHandleExitNotShutdown = true);
00059
00061 AREXPORT static void uninit();
00062
00064 AREXPORT static void addInitCallBack(ArFunctor *cb, ArListPos::Pos position);
00065
00067 AREXPORT static void addUninitCallBack(ArFunctor *cb,
00068 ArListPos::Pos position);
00069
00071 AREXPORT static void shutdown();
00072
00074 AREXPORT static void exit(int exitCode = 0);
00075
00077 AREXPORT static bool getRunning(void);
00078
00080 AREXPORT static void setDirectory(const char * directory);
00081
00083 AREXPORT static const char *getDirectory(void);
00084
00086 AREXPORT static bool parseArgs(void);
00087
00089 AREXPORT static void logOptions(void);
00090
00092 AREXPORT static void setKeyHandler(ArKeyHandler *keyHandler);
00093
00095 AREXPORT static ArKeyHandler *getKeyHandler(void);
00096
00098 AREXPORT static void setJoyHandler(ArJoyHandler *joyHandler);
00099
00101 AREXPORT static ArJoyHandler *getJoyHandler(void);
00102
00104 AREXPORT static void addExitCallback(ArFunctor *functor, int position = 50);
00105
00107 AREXPORT static void exitOld(int exitCode = 0);
00108
00110 AREXPORT static void signalHandlerCB(int sig);
00111
00113 AREXPORT static void callExitCallbacks(void);
00114
00116 AREXPORT static void addParseArgsCB(ArRetFunctor<bool> *functor,
00117 int position = 50);
00118
00120 AREXPORT static void setParseArgLogLevel(ArLog::LogLevel level);
00121
00123 AREXPORT static void addLogOptionsCB(ArFunctor *functor, int position = 50);
00124
00125 #ifndef ARINTERFACE
00126
00127 AREXPORT static void setRobotJoyHandler(ArRobotJoyHandler *robotJoyHandler);
00128
00130 AREXPORT static ArRobotJoyHandler *getRobotJoyHandler(void);
00131
00133 AREXPORT static ArConfig *getConfig(void);
00134
00136 AREXPORT static ArStringInfoGroup *getInfoGroup(void);
00137
00139 AREXPORT static void addRobot(ArRobot *robot);
00140
00142 AREXPORT static void delRobot(ArRobot *robot);
00143
00145 AREXPORT static ArRobot *findRobot(char *name);
00146
00148 AREXPORT static std::list<ArRobot*> * getRobotList();
00149 #endif // ARINTERFACE
00150 protected:
00151 static bool ourInited;
00152 static ArGlobalFunctor1<int> ourSignalHandlerCB;
00153 static bool ourRunning;
00154 static ArMutex ourShuttingDownMutex;
00155 static bool ourShuttingDown;
00156 static bool ourExiting;
00157 static std::string ourDirectory;
00158 static std::list<ArFunctor*> ourInitCBs;
00159 static std::list<ArFunctor*> ourUninitCBs;
00160 static ArKeyHandler *ourKeyHandler;
00161 static ArJoyHandler *ourJoyHandler;
00162 #ifndef ARINTERFACE
00163 static std::list<ArRobot*> ourRobots;
00164 static ArRobotJoyHandler *ourRobotJoyHandler;
00165 static ArConfig ourConfig;
00166 static ArStringInfoGroup ourInfoGroup;
00167 #endif // ARINTERFACE
00168 static ArMutex ourExitCallbacksMutex;
00169 static std::multimap<int, ArFunctor *> ourExitCallbacks;
00170 static bool ourSigHandleExitNotShutdown;
00171 static std::multimap<int, ArRetFunctor<bool> *> ourParseArgCBs;
00172 static ArLog::LogLevel ourParseArgsLogLevel;
00173 static std::multimap<int, ArFunctor *> ourLogOptionsCBs;
00174 };
00175
00176
00177 #endif // ARIAINTERNAL_H