/** * 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; }
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; }
OfxhMajorPlugin( OfxhPlugin& iep ) : _id( iep.getIdentifier() ) , _major( iep.getVersionMajor() ) {}