17 #ifndef _GZ_PLUGIN_HH_    18 #define _GZ_PLUGIN_HH_    33 #include <sys/types.h>    36 #include <gazebo/gazebo_config.h>    86     public: 
typedef boost::shared_ptr<T> 
TPtr;
    91               this->dlHandle = 
NULL;
   122     public: 
static TPtr 
Create(
const std::string &_filename,
   123                 const std::string &_name)
   129               std::string fullname, 
filename(_filename);
   130               std::list<std::string>::iterator iter;
   131               std::list<std::string> pluginPaths =
   138                 size_t soSuffix = filename.rfind(
".so");
   139                 const std::string macSuffix(
".dylib");
   140                 if (soSuffix != std::string::npos)
   141                   filename.replace(soSuffix, macSuffix.length(), macSuffix);
   143 #endif  // ifdef __APPLE__   145               for (iter = pluginPaths.begin();
   146                    iter!= pluginPaths.end(); ++iter)
   148                 fullname = (*iter)+std::string(
"/")+
filename;
   149                 if (stat(fullname.c_str(), &st) == 0)
   159               fptr_union_t registerFunc;
   160               std::string registerName = 
"RegisterPlugin";
   162               void *dlHandle = dlopen(fullname.c_str(), RTLD_LAZY|RTLD_GLOBAL);
   165                 gzerr << 
"Failed to load plugin " << fullname << 
": "   166                   << dlerror() << 
"\n";
   170               registerFunc.ptr = dlsym(dlHandle, registerName.c_str());
   172               if (!registerFunc.ptr)
   174                 gzerr << 
"Failed to resolve " << registerName
   175                       << 
": " << dlerror();
   180               result.reset(registerFunc.func());
   181               result->dlHandle = dlHandle;
   183               result->handleName = _name;
   206     private: 
typedef union   213     private: 
void *dlHandle;
   236                               sdf::ElementPtr _sdf) = 0;
   261                               sdf::ElementPtr _sdf) = 0;
   290                               sdf::ElementPtr _sdf) = 0;
   317     public: 
virtual void Load(
int _argc = 0, 
char **_argv = 
NULL) = 0;
   343                               sdf::ElementPtr _sdf) = 0;
   361 #define GZ_REGISTER_MODEL_PLUGIN(classname) \   362   extern "C" GZ_COMMON_VISIBLE gazebo::ModelPlugin *RegisterPlugin(); \   363   gazebo::ModelPlugin *RegisterPlugin() \   365     return new classname();\   372 #define GZ_REGISTER_WORLD_PLUGIN(classname) \   373   extern "C" GZ_COMMON_VISIBLE gazebo::WorldPlugin *RegisterPlugin(); \   374   gazebo::WorldPlugin *RegisterPlugin() \   376     return new classname();\   383 #define GZ_REGISTER_SENSOR_PLUGIN(classname) \   384   extern "C" GZ_COMMON_VISIBLE gazebo::SensorPlugin *RegisterPlugin(); \   385   gazebo::SensorPlugin *RegisterPlugin() \   387     return new classname();\   394 #define GZ_REGISTER_SYSTEM_PLUGIN(classname) \   395   extern "C" GZ_COMMON_VISIBLE gazebo::SystemPlugin *RegisterPlugin(); \   397   gazebo::SystemPlugin *RegisterPlugin() \   399     return new classname();\   406 #define GZ_REGISTER_VISUAL_PLUGIN(classname) \   407   extern "C" GZ_COMMON_VISIBLE gazebo::VisualPlugin *RegisterPlugin(); \   408   gazebo::VisualPlugin *RegisterPlugin() \   410     return new classname();\ std::shared_ptr< Sensor > SensorPtr
Definition: SensorTypes.hh:63
 
std::string handleName
Short name. 
Definition: Plugin.hh:203
 
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:84
 
Forward declarations for the common classes. 
Definition: Animation.hh:33
 
std::string filename
Path to the shared library file. 
Definition: Plugin.hh:200
 
std::string GetFilename() const
Get the name of the handler. 
Definition: Plugin.hh:106
 
static TPtr Create(const std::string &_filename, const std::string &_name)
a class method that creates a plugin from a file name. 
Definition: Plugin.hh:122
 
virtual void Reset()
Definition: Plugin.hh:239
 
std::string GetHandle() const
Get the short name of the handler. 
Definition: Plugin.hh:112
 
PluginType type
Type of plugin. 
Definition: Plugin.hh:197
 
A plugin with access to physics::World. 
Definition: Plugin.hh:220
 
A plugin loaded within the gzserver on startup. 
Definition: Plugin.hh:331
 
virtual void Init()
Override this method for custom plugin initialization behavior. 
Definition: Plugin.hh:293
 
#define gzerr
Output an error message. 
Definition: Console.hh:50
 
A World plugin. 
Definition: Plugin.hh:66
 
virtual void Reset()
Override this method for custom plugin reset behavior. 
Definition: Plugin.hh:325
 
default namespace for gazebo 
 
virtual void Reset()
Override this method for custom plugin reset behavior. 
Definition: Plugin.hh:351
 
A plugin loaded within the gzserver on startup. 
Definition: Plugin.hh:303
 
A GUI plugin. 
Definition: Plugin.hh:76
 
PluginType
Used to specify the type of plugin. 
Definition: Plugin.hh:63
 
A Sensor plugin. 
Definition: Plugin.hh:70
 
virtual void Reset()
Override this method for custom plugin reset behavior. 
Definition: Plugin.hh:267
 
virtual void Reset()
Override this method for custom plugin reset behavior. 
Definition: Plugin.hh:296
 
virtual void Init()
Definition: Plugin.hh:238
 
virtual ~PluginT()
Destructor. 
Definition: Plugin.hh:95
 
virtual ~SystemPlugin()
Destructor. 
Definition: Plugin.hh:310
 
boost::shared_ptr< T > TPtr
plugin pointer type definition 
Definition: Plugin.hh:86
 
VisualPlugin()
Definition: Plugin.hh:333
 
virtual void Init()
Initialize the plugin. 
Definition: Plugin.hh:348
 
PluginType GetType() const
Returns the type of the plugin. 
Definition: Plugin.hh:191
 
#define NULL
Definition: CommonTypes.hh:31
 
A class which all plugins must inherit from. 
Definition: Plugin.hh:83
 
SystemPlugin()
Constructor. 
Definition: Plugin.hh:306
 
A Model plugin. 
Definition: Plugin.hh:68
 
ModelPlugin()
Constructor. 
Definition: Plugin.hh:248
 
virtual ~WorldPlugin()
Destructor. 
Definition: Plugin.hh:227
 
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:112
 
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:88
 
SensorPlugin()
Constructor. 
Definition: Plugin.hh:277
 
Forward declarations and typedefs for sensors. 
 
WorldPlugin()
Constructor. 
Definition: Plugin.hh:223
 
virtual void Init()
Initialize the plugin. 
Definition: Plugin.hh:322
 
virtual ~SensorPlugin()
Destructor. 
Definition: Plugin.hh:281
 
A Visual plugin. 
Definition: Plugin.hh:74
 
PluginT()
Constructor. 
Definition: Plugin.hh:89
 
A plugin with access to physics::Sensor. 
Definition: Plugin.hh:274
 
A plugin with access to physics::Model. 
Definition: Plugin.hh:245
 
virtual ~ModelPlugin()
Destructor. 
Definition: Plugin.hh:252
 
virtual void Init()
Override this method for custom plugin initialization behavior. 
Definition: Plugin.hh:264
 
static SystemPaths * Instance()
Get an instance of the singleton. 
Definition: SingletonT.hh:36
 
A System plugin. 
Definition: Plugin.hh:72