Aria: ArModule Class Reference

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# ArModule Class Reference

`#include <ArModule.h>`

List of all members.

## Detailed Description

Dynamicly loaded module base class, read warning in more.

Right now only one module's init will be called, that is the first one, its a bug that I just don't have time to fix at the moment. I'll get to it when I have time or if someone needs it... someone else wrote this code so it'll take me a little longer to fix it.

This class defines a dyanicmly loaded module of code. This is usefull for an application to load piece of code that it does not know about. The ArModule defines and interface in which to invoke that piece of code that the program does not know about. For instance, a module could contain an ArAction and the modules init() could instantiate the ArAction and add it to the supplied ArRobot. The init() takes a reference to an ArRobot. The module should use that robot for its purposes. If the module wants to use more robots, assuming there are multiple robots, it can use Aria::getRobotList() to find all the ArRobot instantiated. The module should do all its clean up in exit().

The user should derive their own class from ArModule and implement the init() and exit() functions. The users code should always clean up when exit() is called. exit() is called right before the module (dynamic library .dll/.so) is closed and removed from the program.

The macro ARDEF_MODULE() must be called within the .cpp file of the users module. A global instance of the users module must be defined and a reference to that instance must be passed to ARDEF_MODULE(). This allows the ArModuleLoader to find the users module class and invoke it.

One thing to note about the use of code wrapped in ArModules and staticly linking in that code. To be able to staticly link .cpp files which contain an ArModule, the ARIA_STATIC preprocessor symbol should be defined. This will cause the ARDEF_MODULE() to do nothing. If it defined its normal functions and variables, the linker would fail to staticly link in multiple modules since they all have symbols with the same name.

Refer to ArModuleLoader to see how to load an ArModule into a program.

For examples, see the programs advanced/simpleMod.cpp and advanced/simpleModule.cpp.

## Public Member Functions
| ArModule ()
| Constructor.
virtual bool | exit ()=0
| Close down the module and have it exit.
ArRobot * | getRobot ()
| Get the ArRobot pointer the module should be using.
virtual bool | init (ArRobot *robot, void *argument=NULL)=0
| Initialize the module. The module should use the supplied ArRobot pointer.
void | setRobot (ArRobot *robot)
| Set the ArRobot pointer.
virtual | ~ArModule ()
| Destructor.
## Protected Attributes
ArRobot * | myRobot
| Stored ArRobot pointer that the module should use.

## Member Function Documentation

virtual bool ArModule::init | ( | ArRobot * | robot,
|  | void * | argument = `NULL` |
| ) |  |  | `[pure virtual]`

Initialize the module. The module should use the supplied ArRobot pointer.

Parameters:

  | robot | Robot this module should attach to, can be NULL for none, so make sure you handle that case
  | modArgument | an optional string argument to the module, this defaults to NULL, you'll need to cast this to whatever you want it to be... you'll want to document this clearly with the module

The documentation for this class was generated from the following file:

- ArModule.h