#include <ariaInternal.h>
Public Types | |
enum | SigHandleMethod { SIGHANDLE_SINGLE, SIGHANDLE_THREAD, SIGHANDLE_NONE } |
Static Public Member Functions | |
static void | addExitCallback (ArFunctor *functor, int position=50) |
Adds a functor to call on Aria::exit. | |
static void | addInitCallBack (ArFunctor *cb, ArListPos::Pos position) |
Adds a callback to call when Aria is inited. | |
static void | addRobot (ArRobot *robot) |
Add a robot to the global list of robots. | |
static void | addUninitCallBack (ArFunctor *cb, ArListPos::Pos position) |
Adds a callback to call when Aria is uninited. | |
static void | callExitCallbacks (void) |
Internal, calls the exit callbacks. | |
static void | delRobot (ArRobot *robot) |
Remove a robot from the global list of robots. | |
static void | exit (int exitCode=0) |
Force an exit of all Aria processes/threads. | |
static void | exitOld (int exitCode=0) |
Force an exit of all Aria processes/threads (the old way). | |
static ArRobot * | findRobot (char *name) |
Finds a robot in the global list of robots, by name. | |
static ArConfig * | getConfig (void) |
Gets the ArConfig for this program. | |
static const char * | getDirectory (void) |
Gets the directory that ARIA resides in. | |
static ArJoyHandler * | getJoyHandler (void) |
Gets the joystick handler if one has been set. | |
static ArKeyHandler * | getKeyHandler (void) |
Gets the joystick handler if one has been set. | |
static ArRobotJoyHandler * | getRobotJoyHandler (void) |
Gets the robot joystick handler if one has been set. | |
static std::list< ArRobot * > * | getRobotList () |
Get a copy of the global robot list. | |
static bool | getRunning (void) |
Sees if Aria is still running (mostly for the thread in main). | |
static void | init (SigHandleMethod method=SIGHANDLE_THREAD, bool initSockets=true, bool sigHandleExitNotShutdown=true) |
Performs OS-specific initialization. | |
static void | setDirectory (const char *directory) |
Sets the directory that ARIA resides in. | |
static void | setJoyHandler (ArJoyHandler *joyHandler) |
Sets the joystick handler, so that other classes can find it. | |
static void | setKeyHandler (ArKeyHandler *keyHandler) |
Sets the key handler, so that other classes can find it. | |
static void | setRobotJoyHandler (ArRobotJoyHandler *robotJoyHandler) |
Sets the robot joystick handler, so that other classes can find it. | |
static void | shutdown () |
Shutdown all Aria processes/threads. | |
static void | signalHandlerCB (int sig) |
Internal, the callback for the signal handling. | |
static void | uninit () |
Performs OS-specific deinitialization. | |
Static Protected Attributes | |
static ArConfig | ourConfig |
static std::string | ourDirectory = "" |
static std::multimap< int, ArFunctor * > | ourExitCallbacks |
static ArMutex | ourExitCallbacksMutex |
static std::list< ArFunctor * > | ourInitCBs |
static bool | ourInited = false |
static ArJoyHandler * | ourJoyHandler = NULL |
static ArKeyHandler * | ourKeyHandler = NULL |
static ArRobotJoyHandler * | ourRobotJoyHandler = NULL |
static std::list< ArRobot * > | ourRobots |
static bool | ourRunning = false |
static bool | ourShuttingDown = false |
static ArMutex | ourShuttingDownMutex |
static bool | ourSigHandleExitNotShutdown = true |
static ArGlobalFunctor1< int > | ourSignalHandlerCB |
static std::list< ArFunctor * > | ourUninitCBs |
Definition at line 41 of file ariaInternal.h.
|
Definition at line 45 of file ariaInternal.h. |
|
Adds a callback to call when Aria is inited. This will add a callback to the list of callbacks to call when Aria has been initialized. It can be called before anything else. |
|
Adds a callback to call when Aria is uninited. This will add a callback to the list of callbacks to call right before Aria is un-initialized. It can be called before anything else. This facilitates code that in operating system signal handlers simply calls Aria::uninit() and packages that are based on Aria are unitited as well. It simplifies the entire uninit process. Definition at line 208 of file Aria.cpp. Referenced by ArP2Arm::init(). |
|
Force an exit of all Aria processes/threads. This will call the list of Aria exit callbacks and then exit with the given exit code. Note that this could be called from anywhere and things may be locked or unlocked when called and the exit callbacks MUST exit and cannot wait for a lock. Definition at line 248 of file Aria.cpp. References callExitCallbacks(), ArMutex::lock(), and ArMutex::unlock(). Referenced by ArRobot::keyHandlerExit(), and signalHandlerCB(). |
|
Force an exit of all Aria processes/threads (the old way). This method is roughly obsolete, it forces all the threads to die and then exits... The new way is exit. This calls cancel() on all AtThread's and ArASyncTask's. It forces each thread to exit and should only be used in the case of a thread hanging or getting stuck in an infinite loop. This works fine in Linux. In Windows it is not recommended at all that this function be called. Windows can not handle cleanly killing off a thread. See the help in the VC++ compiler on the WIN32 function TerminateThread. The biggest problem is that the state of DLL's can be destroyed. Definition at line 326 of file Aria.cpp. References ArThread::cancelAll(), and uninit(). |
|
Finds a robot in the global list of robots, by name.
|
|
Gets the ArConfig for this program. This gets the global config aria uses. Definition at line 503 of file Aria.cpp. Referenced by ArMap::ArMap(). |
|
Gets the directory that ARIA resides in. This gets the directory that ARIA is located in, this is so ARIA can find param files and the like.
Definition at line 448 of file Aria.cpp. Referenced by ArRobot::madeConnection(). |
|
Sees if Aria is still running (mostly for the thread in main). This returns if the ARIA stuff is running, which is defined as the time between Aria::init and any of Aria::shutdown, Aria::exit, or the signal handler kicking off. |
|
Performs OS-specific initialization. This must be called first before any other Aria functions. It initializes the thread layer and the signal handling method. For Windows it iniatializes the socket layer as well. This also sets the directory Aria is located in from the ARIA environmental variable, for a description of this see getDirectory and setDirectory. For Linux the default signal handling method is to cleanly close down the program, cause all the instances of ArRobot to stop their run loop and disconnect from their robot. The program will exit on the following signals: SigHUP, SigINT, SigQUIT, and SigTERM. For Windows, there is no signal handling. This also intializes the default argument locations to the file /etc/Aria and to the environmental variable ARIAARGS. The contents of those files and variables will be loaded by ArArgumentParser::loadDefaultArgs into the parser.
Definition at line 83 of file Aria.cpp. References ArArgumentParser::addDefaultArgumentEnv(), ArArgumentParser::addDefaultArgumentFile(), ArSignalHandler::addHandlerCB(), ArSignalHandler::blockCommon(), ArSignalHandler::blockCommonThisThread(), ArSignalHandler::createHandlerNonThreaded(), ArSignalHandler::createHandlerThreaded(), ArUtil::getStringFromFile(), ArSignalHandler::handle(), ArSocket::init(), ArThread::init(), ArLog::log(), setDirectory(), SIGHANDLE_NONE, SIGHANDLE_SINGLE, and SIGHANDLE_THREAD. |
|
Sets the directory that ARIA resides in. This sets the directory that ARIA is located in, so ARIA can find param files and the like. This can also be controlled by the environment variable ARIA, which this is set to (if it exists) when Aria::init is done. So for setDirectory to be effective, it must be done after the Aria::init.
Definition at line 421 of file Aria.cpp. References ArConfig::setBaseDirectory(). Referenced by init(). |
|
Shutdown all Aria processes/threads. This calls stop() on all ArThread's and ArASyncTask's. It will block until all ArThread's and ArASyncTask's exit. It is expected that all the tasks will obey the ArThread::myRunning variable and exit when it is false. Definition at line 222 of file Aria.cpp. References ArThread::joinAll(), ArMutex::lock(), ArThread::stopAll(), uninit(), and ArMutex::unlock(). Referenced by ArRobot::keyHandlerExit(), and signalHandlerCB(). |
|
Performs OS-specific deinitialization. This must be called last, after all other Aria functions. For both Linux and Windows, it closes all the open ArModules. For Windows it deinitializes the socket layer as well. Definition at line 178 of file Aria.cpp. References ArModuleLoader::closeAll(), and ArSocket::shutdown(). Referenced by exitOld(), and shutdown(). |