/usr/include/Aria/ArModule.h is in libaria-dev 2.8.0+repack-1.2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /*
Adept MobileRobots Robotics Interface for Applications (ARIA)
Copyright (C) 2004, 2005 ActivMedia Robotics LLC
Copyright (C) 2006, 2007, 2008, 2009, 2010 MobileRobots Inc.
Copyright (C) 2011, 2012, 2013 Adept Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
If you wish to redistribute ARIA under different terms, contact
Adept MobileRobots for information about a commercial version of ARIA at
robots@mobilerobots.com or
Adept MobileRobots, 10 Columbia Drive, Amherst, NH 03031; +1-603-881-7960
*/
#ifndef ARMODULE_H
#define ARMODULE_H
#include "ariaTypedefs.h"
#include "ArRobot.h"
/// 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.
*/
class ArModule
{
public:
/// Constructor
AREXPORT ArModule();
/// Destructor
AREXPORT virtual ~ArModule();
/// Initialize the module. The module should use the supplied ArRobot pointer
/**
@param robot Robot this module should attach to or operate on. Note, may be NULL.
@param argument an optional argument passed to the module. Default
is NULL. The module can interpret this in any way, it is recommended
that you make sure this is documented if used.
*/
AREXPORT virtual bool init(ArRobot *robot,
void *argument = NULL) = 0;
/// Close down the module and have it exit
AREXPORT virtual bool exit() = 0;
/// Get the ArRobot pointer the module should be using
AREXPORT ArRobot * getRobot() {return(myRobot);}
/// Set the ArRobot pointer
AREXPORT void setRobot(ArRobot *robot) {myRobot=robot;}
protected:
/// Stored ArRobot pointer that the module should use
ArRobot *myRobot;
};
/*
Beware ye all who pass beyond this point. Ugly macros abound and you might
get eaten by a gru if your light fails. */
#ifdef ARIA_STATIC
#define ARDEF_MODULE(mod)
#else
#ifdef WIN32
#define ARDEF_MODULE(mod) \
extern "C" {\
static ArModule *__AriaModule_##mod = &mod; \
_declspec(dllexport) bool \
ariaInitModule(ArRobot *robot, void *argument = NULL) \
{ \
if (__AriaModule_##mod) \
{ \
__AriaModule__->setRobot(robot); \
return(__AriaModule_##mod->init(robot, argument)); \
} \
else \
return(false); \
} \
_declspec(dllexport) bool ariaExitModule() \
{ \
if (__AriaModule_##mod) \
return(__AriaModule_##mod->exit()); \
return(false); \
} \
}
#else // WIN32
#define ARDEF_MODULE(mod) \
static ArModule *__AriaModule_##mod = &mod; \
extern "C" {\
bool ariaInitModule(ArRobot *robot, void *argument = NULL) \
{ \
if (__AriaModule_##mod) \
{ \
__AriaModule_##mod->setRobot(robot); \
return(__AriaModule_##mod->init(robot, argument)); \
} \
else \
return(false); \
} \
bool ariaExitModule() \
{ \
if (__AriaModule_##mod) \
return(__AriaModule_##mod->exit()); \
return(false); \
} \
}
#endif // WIN32
#endif // ARIA_STATIC
#endif // ARMODULE_H
|