/** * get the plugin by id. vermaj and vermin can be specified. if they are not it will * pick the highest found version. */ OfxhPlugin* OfxhPluginCache::getPluginById( const std::string& id, int vermaj, int vermin ) { if( vermaj == -1 && vermin == -1 ) return _pluginsByID[id]; // return the highest version one, which fits the pattern provided OfxhPlugin* sofar = 0; for( std::list<OfxhPlugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i ) { OfxhPlugin* p = *i; if( p->getIdentifier() != id ) { continue; } if( vermaj != -1 && p->getVersionMajor() != vermaj ) { continue; } if( vermin != -1 && p->getVersionMinor() != vermin ) { continue; } if( !sofar || p->trumps( *sofar ) ) { sofar = p; } } return sofar; }
OfxhImageEffectNodeDescriptor::OfxhImageEffectNodeDescriptor( const OfxhImageEffectNodeDescriptor& other, OfxhPlugin& plug ) : OfxhImageEffectNodeBase( other._properties ) , _plugin( &plug ) { _properties.setStringProperty( kOfxPluginPropFilePath, plug.getBinary().getBundlePath() ); tuttle::host::Core::instance().getHost().initDescriptor( *this ); }
bool trumps(OfxhPlugin& other) { int myMajor = getVersionMajor(); int theirMajor = other.getVersionMajor(); int myMinor = getVersionMinor(); int theirMinor = other.getVersionMinor(); if(myMajor > theirMajor) { return true; } if(myMajor == theirMajor && myMinor > theirMinor) { return true; } return false; }
OfxhPluginLoadGuard::OfxhPluginLoadGuard( OfxhPlugin& plugin, OfxhHost& host ) : _plugin( &plugin ) , _pluginBinary( &plugin.getBinary() ) , _rawOfxPlugin( 0 ) { _pluginBinary->_binary.ref(); OfxGetPluginType getPlugin_func = (OfxGetPluginType)_pluginBinary->_binary.findSymbol( "OfxGetPlugin" ); _rawOfxPlugin = getPlugin_func( _plugin->getIndex() ); if( !_rawOfxPlugin ) { // We throw inside the constructor, so the destructor will not be called. _pluginBinary->_binary.unref(); BOOST_THROW_EXCEPTION( exception::Data() << exception::user( "Loading plugin failed." ) << exception::dev() + "OfxGetPlugin call failed at index " + _plugin->getIndex() + "." << exception::filename( _pluginBinary->getBundlePath() ) ); } _rawOfxPlugin->setHost( host.getHandle() ); }
OfxhMajorPlugin( OfxhPlugin& iep ) : _id( iep.getIdentifier() ) , _major( iep.getVersionMajor() ) {}