OpenIG  2.0.4
cross-platform open-source OpenSceneGraph Image Generator
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
OpenIG::PluginBase::Plugin Class Referenceabstract

The Plugin class. More...

#include <Plugin.h>

Inheritance diagram for OpenIG::PluginBase::Plugin:

Public Member Functions

 Plugin ()
 Constructor. More...
 
virtual std::string getName ()=0
 The name of the plugin. More...
 
virtual std::string getDescription ()=0
 The description of the plugin. More...
 
virtual std::string getVersion ()=0
 The version of the plugin. More...
 
virtual std::string getAuthor ()=0
 The author of the plugin. More...
 
std::string getLibrary () const
 The shared library name where the plugin is defined. More...
 
int getOrderNumber () const
 The order number of the plugin. More...
 
virtual void databaseRead (const std::string &, osg::Node *, const osgDB::Options *)
 Hook for database read. More...
 
virtual void databaseReadInVisitorBeforeTraverse (osg::Node &, const osgDB::Options *)
 Hook for begining of the loaded model traveral. More...
 
virtual void databaseReadInVisitorAfterTraverse (osg::Node &)
 Hook for begining of the loaded model traveral. More...
 
virtual void config (const std::string &)
 Method to configure the plugin from a XML file. More...
 
virtual void init (PluginContext &)
 Method to init the plugin with a given igplugincore::PluginContext. More...
 
virtual void update (PluginContext &)
 Update hook. More...
 
virtual void preFrame (PluginContext &, double)
 Preframe hook. More...
 
virtual void postFrame (PluginContext &, double)
 Postframe hook. More...
 
virtual void clean (PluginContext &)
 Method called on exit to give the user chance to perform cleanup. More...
 
virtual void entityAdded (PluginContext &, unsigned int, osg::Node &, const std::string &)
 Hook called when OpenIG::Base::Entity is added to the scene. More...
 
virtual void beginningOfFrame (PluginContext &)
 Hook called on the very beginning of the frame before any processing. More...
 
virtual void endOfFrame (PluginContext &)
 Hook called on the end of the frame after all the frame processing. More...
 

Protected Member Functions

void setLibrary (const std::string &library)
 The order number of the plugin. See igplugincore::Plugin::getOrderNumber. More...
 
void setOrderNumber (int orderNumber)
 Sets the plugin order number. More...
 

Protected Attributes

std::string _library
 
int _orderNumber
 The shared library file name where this plugin is implemented.
 

Friends

class PluginHost
 

Detailed Description

The Plugin class.

The OpenIG Image Generator is designed with plugin-in based architecture This class is the abstract interface definition of a plugin

As the Plugin is defined, it is providing methods that are hooks giving the writers of inheritants chance to intercept in events happening in the OpenIG. These events are the visual database or model loading, hooks in the DatabaseReadCallback, in the OpenIG::Base::ImageGenerator::frame method for update and pre/post frame processing, on OpenIG::Base::ImageGenerator::Entity addition.

In OpenIG, a DatabaseReadCallback is implemented in a way that uses the default osg read implementatoion and then it calls all the plugins loaded method igplugincore::Plugin::databaseRead to postprocess the loaded model before it's addition to the scene. Example can be the igplugins::LightingPlugin that traverse the loaded model, looks for runways and adds shader based light sources as addition to the light points After the process of the loading of the model, there is NodeVisitor applied to the model, which calls the igplugincore::Plugin::databaseReadInVisitorBeforeTraverse and igplugincore::Plugin::databaseReadInVisitorAfterTraverse hook methods. It is a common place to use this one NodeVisitor and perform actions/settings on nodes from the loaded model. Here is a snippet in pseudo code for the DatabaseReadCallback - for details refer to the source.

class DatabaseReadCallback : public osgDB::Registry::ReadFileCallback
{
....
virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& filename, const osgDB::Options* options)
{
osgDB::ReaderWriter::ReadResult result = osgDB::Registry::instance()->readNodeImplementation(filename,options);
if (result.getNode())
{
// Call the databaseRead hook on all plugins
// through PluginOperation
Plugin::databaseRead(filename,options);
// Traverse the model and calls
// the other mention hooks, see bellow
DatabaseReadNodeVisitor nv;
result.getNode()->accept(nv);
}
return result;
}
....
};
class DatabaseReadNodeVisitor : public osg::NodeVisitor
{
...
virtual void apply(osg::Node& node)
{
// Call all the plugins hook before
// traversal
traverse(node);
// Call all the plugins hook
// after traversal
}
...
};

The other hooks are tied in OpenIG::Base::ImageGenerator::init to give chance to init and configure the plugins. These are:

Then the frame hooks, that are happening each frame:

And the last hook added is for the addEntity event, happens in OpenIG::Base::ImageGenerator::addEntity

Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015

Constructor & Destructor Documentation

OpenIG::PluginBase::Plugin::Plugin ( )
inline

Constructor.

Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015

Member Function Documentation

virtual void OpenIG::PluginBase::Plugin::beginningOfFrame ( PluginContext )
inlinevirtual

Hook called on the very beginning of the frame before any processing.

Hook called on the very beginning of the frame before any processing.

Parameters
theigplugincore::PluginContext
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sat May 14 2016
virtual void OpenIG::PluginBase::Plugin::clean ( PluginContext )
inlinevirtual

Method called on exit to give the user chance to perform cleanup.

Hook called on exit to give the user chance to perform cleanup See OpenIG::Base::ImageGenerator::frame for more info

Parameters
Theigplugincore::PluginContext
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::config ( const std::string &  )
inlinevirtual

Method to configure the plugin from a XML file.

Method to configure the plugin from a XML file. It is called once at OpenIG::Base::ImageGenerator::init. The file name is composed from the file name of the library containing the plugin implementation with .xml extension

Parameters
Thefile name of the XML configuration
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::databaseRead ( const std::string &  ,
osg::Node *  ,
const osgDB::Options *   
)
inlinevirtual

Hook for database read.

This is a hook that is attached to a database read callback in osg. It is called when load of a model is happened and gives the user to intercept this event and perform custom operation from within the plugin

Parameters
Thefirst parameter is the file name of the model loaded
Thesecond parameter is the osg::Node representing the loaded model
Thelast parameter is the osgDB::Options provided for loading of the model
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::databaseReadInVisitorAfterTraverse ( osg::Node &  )
inlinevirtual

Hook for begining of the loaded model traveral.

Hook for end of the loaded model traveral. The mention database read callback is traversing the loaded model and this method is called after traversal. It gives the user ability to perform operations on all the nodes being traversed. Example can be the LightingPlugin which replaces lightpoints in the loaded model with real lights computed in a shader

Parameters
Thenode traversed is the first parameter
Theoptions used to load the model
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::databaseReadInVisitorBeforeTraverse ( osg::Node &  ,
const osgDB::Options *   
)
inlinevirtual

Hook for begining of the loaded model traveral.

Hook for begining of the loaded model traveral. The mention database read callback is traversing the loaded model and this method is called before traversal. It gives the user ability to perform operations on all the nodes being traversed. Example can be the LightingPlugin which replaces lightpoints in the loaded model with real lights computed in a shader

Parameters
Thenode traversed is the first parameter
Theoptions used to load the model
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::endOfFrame ( PluginContext )
inlinevirtual

Hook called on the end of the frame after all the frame processing.

Hook called on the end of the frame after all the frame processing.

Parameters
theigplugincore::PluginContext
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sat May 14 2016
virtual void OpenIG::PluginBase::Plugin::entityAdded ( PluginContext ,
unsigned  int,
osg::Node &  ,
const std::string &   
)
inlinevirtual

Hook called when OpenIG::Base::Entity is added to the scene.

Hook called when OpenIG::Base::Entity is added to the scene. This gives the user chance to intercept this event and perform actions on the OpenIG::Base::Entity when it is added to the scene with OpenIG::Base::ImageGenerator::addEntity

Parameters
theigplugincore::PluginContext
theOpenIG::Base::ImageGenerator::Entity ID assigned
theosg::Node representing this OpenIG::Base::ImageGenerator::Entity
thefilename of the model
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual std::string OpenIG::PluginBase::Plugin::getAuthor ( )
pure virtual

The author of the plugin.

Returns
The author of the plugin
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual std::string OpenIG::PluginBase::Plugin::getDescription ( )
pure virtual

The description of the plugin.

Ihnerits are requred to provide description of what the implemented plugin does

Returns
The description of the plugin
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
std::string OpenIG::PluginBase::Plugin::getLibrary ( ) const
inline

The shared library name where the plugin is defined.

The shared library name where the plugin is defined. This is set by the igplugincore::PluginHost

Returns
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual std::string OpenIG::PluginBase::Plugin::getName ( )
pure virtual

The name of the plugin.

The name of the plugin. It is used by the igplugincore::PluginHost to manage them. The active plugins are mentioned in the opeing::OpenIG configuration file openig.xml on Windows found in igdata folder, on Linux and MacOS in /usr/local/lib/igdata.

Returns
The name of the plugin
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
int OpenIG::PluginBase::Plugin::getOrderNumber ( ) const
inline

The order number of the plugin.

The order number of the plugin. It is read by the igplugincore::PluginHost from the configuration file as openig.xml is. The plugins are then executed based on their order number

Returns
The order number of the plugin
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual std::string OpenIG::PluginBase::Plugin::getVersion ( )
pure virtual

The version of the plugin.

Returns
The version of the plugin
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::init ( PluginContext )
inlinevirtual

Method to init the plugin with a given igplugincore::PluginContext.

Method to init the plugin with a given igplugincore::PluginContext. The igplugincore::PluginHost is calling this once to give the user to perform initialization of the plugin

Parameters
Theigplugincore::PluginContext
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::postFrame ( PluginContext ,
double   
)
inlinevirtual

Postframe hook.

postFrame hook. This is called in a frame with a given igplugincore::PluginContext.\ See OpenIG::Base::ImageGenerator::frame for more info

Parameters
Theigplugincore::PluginContext
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::preFrame ( PluginContext ,
double   
)
inlinevirtual

Preframe hook.

preFrame hook. This is called in a frame with a given igplugincore::PluginContext.\ See OpenIG::Base::ImageGenerator::frame for more info

Parameters
Theigplugincore::PluginContext
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
void OpenIG::PluginBase::Plugin::setLibrary ( const std::string &  library)
inlineprotected

The order number of the plugin. See igplugincore::Plugin::getOrderNumber.

Sets the shared library file name. igplugincore::PluginHost is setting this internaly Sets the shared library file name

Parameters
library
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
void OpenIG::PluginBase::Plugin::setOrderNumber ( int  orderNumber)
inlineprotected

Sets the plugin order number.

Sets the order number of the plugin. The order number of the plugin is set by igplugincore::PluginHost when loading the plugins and in calls the plugin and their plugin hooks in sorted by this number fashion

Parameters
Theorder number of the plugin
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015
virtual void OpenIG::PluginBase::Plugin::update ( PluginContext )
inlinevirtual

Update hook.

Update hook. This is called in a frame with a given igplugincore::PluginContext.\ See OpenIG::Base::ImageGenerator::frame for more info

Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Jan 16 2015

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