Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Aria Class Reference

This class performs global initialization and deinitialization. More...

#include <ariaInternal.h>

List of all members.

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 ArRobotfindRobot (char *name)
 Finds a robot in the global list of robots, by name.
static ArConfiggetConfig (void)
 Gets the ArConfig for this program.
static const char * getDirectory (void)
 Gets the directory that ARIA resides in.
static ArJoyHandlergetJoyHandler (void)
 Gets the joystick handler if one has been set.
static ArKeyHandlergetKeyHandler (void)
 Gets the joystick handler if one has been set.
static ArRobotJoyHandlergetRobotJoyHandler (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 ArJoyHandlerourJoyHandler = NULL
static ArKeyHandlerourKeyHandler = NULL
static ArRobotJoyHandlerourRobotJoyHandler = 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


Detailed Description

This class performs global initialization and deinitialization.

Definition at line 41 of file ariaInternal.h.


Member Enumeration Documentation

enum Aria::SigHandleMethod
 

Enumeration values:
SIGHANDLE_SINGLE  Setup signal handlers in a global, non-thread way.
SIGHANDLE_THREAD  Setup a dedicated signal handling thread.
SIGHANDLE_NONE  Do no signal handling.

Definition at line 45 of file ariaInternal.h.


Member Function Documentation

void Aria::addInitCallBack ArFunctor cb,
ArListPos::Pos  position
[static]
 

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.

Definition at line 193 of file Aria.cpp.

void Aria::addUninitCallBack ArFunctor cb,
ArListPos::Pos  position
[static]
 

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().

void Aria::exit int  exitCode = 0  )  [static]
 

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().

void Aria::exitOld int  exitCode = 0  )  [static]
 

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().

ArRobot * Aria::findRobot char *  name  )  [static]
 

Finds a robot in the global list of robots, by name.

Parameters:
name the name of the robot you want to find
Returns:
NULL if there is no robot of that name, otherwise the robot with that name

Definition at line 349 of file Aria.cpp.

ArConfig * Aria::getConfig void   )  [static]
 

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().

const char * Aria::getDirectory void   )  [static]
 

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.

Returns:
the directory ARIA is located in
See also:
setDirectory

Definition at line 448 of file Aria.cpp.

Referenced by ArRobot::madeConnection().

bool Aria::getRunning void   )  [static]
 

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.

Definition at line 495 of file Aria.cpp.

void Aria::init SigHandleMethod  method = SIGHANDLE_THREAD,
bool  initSockets = true,
bool  sigHandleExitNotShutdown = true
[static]
 

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.

Parameters:
method the method in which to handle signals. Defaulted to SIGHANDLE_SINGLE.
initSockets specify whether or not to initialize the socket layer. This is only meaningfull for Windows. Defaulted to true.
sigHandleExitNotShutdown if this is true and a signal happens Aria will use exit to quit instead of shutdown, false will still use shutdown which is the old behavior
See also:
ArSignalHandler

ArSocket

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.

void Aria::setDirectory const char *  directory  )  [static]
 

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.

Parameters:
directory the directory Aria is located in
See also:
getDirectory

Definition at line 421 of file Aria.cpp.

References ArConfig::setBaseDirectory().

Referenced by init().

void Aria::shutdown  )  [static]
 

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().

void Aria::uninit  )  [static]
 

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().


The documentation for this class was generated from the following files:
Generated on Wed Oct 19 12:56:49 2005 for Aria by  doxygen 1.4.0