Show TPluginManagerProxy.h syntax highlighted
#ifndef __INCLUDE_BY_TPLUGINMANAGER_SPECIALIZED__CLASS__
#error " ERROR osgDesigner/plugins/TPluginManagerProxy.h must no be included directly ERROR !!!"
#error " ===>> Include TPluginManager specialized class' header instead."
#error " ===>> If you want instantiated a new class with the TPluginManager template."
#error " ===>> You must done the specialization for this class."
#error " ===>> See example at the end of the osgDesigner/plugins/TPluginManager.h file."
#endif
#ifndef __TPLUGINMANAGERPROXY__
#define __TPLUGINMANAGERPROXY__ 1
#include <osg/Notify>
/*
* Proxy used for the plugin to register itself
* when loaded and unregister when unloaded
*/
namespace osgDesigner
{
template < typename PluginDesc, typename PluginDescBase >
class TPluginManagerProxy
{
typedef TPluginManager< PluginDescBase > Manager;
public:
TPluginManagerProxy()
{
_pluginDesc = new PluginDesc;
osg::notify(osg::DEBUG_INFO) << "TPluginManagerProxy Manager::instance() = " << Manager::instance() << std::endl;
Manager::instance()->regist(_pluginDesc->getName(), _pluginDesc.get());
osg::notify(osg::DEBUG_INFO) << "Module registered"
<< " Name : " << _pluginDesc->getName() << std::endl
<< " Version : " << _pluginDesc->getVersion() << std::endl
<< " Author : " << _pluginDesc->getAuthor() << std::endl
<< " Description : " << _pluginDesc->getDescription() << std::endl;
}
~TPluginManagerProxy()
{
osg::notify(osg::DEBUG_INFO) << "~TPluginManagerProxy Manager::instance() = " << Manager::instance() << std::endl;
Manager::instance()->unregist(_pluginDesc->getName());
osg::notify(osg::DEBUG_INFO) << "Module unregistered"
<< " Name : " << _pluginDesc->getName() << std::endl
<< " Version : " << _pluginDesc->getVersion() << std::endl
<< " Author : " << _pluginDesc->getAuthor() << std::endl
<< " Description : " << _pluginDesc->getDescription() << std::endl;
_pluginDesc = NULL;
}
protected:
osg::ref_ptr< PluginDesc > _pluginDesc;
};
}
#endif // ** __TPLUGINMANAGERPROXY__ ** //
See more files for this project here