TuttleOFX
1
|
00001 #include "OfxhPluginBinary.hpp" 00002 #include "OfxhPluginCache.hpp" 00003 00004 #include <tuttle/host/exceptions.hpp> 00005 00006 namespace tuttle { 00007 namespace host { 00008 namespace ofx { 00009 00010 /** 00011 * @brief try to open the plugin bundle object and query it for plugins 00012 */ 00013 void OfxhPluginBinary::loadPluginInfo( OfxhPluginCache* cache ) 00014 { 00015 _fileModificationTime = _binary.getTime(); 00016 _fileSize = _binary.getSize(); 00017 _binaryChanged = false; 00018 00019 _binary.load(); 00020 00021 int ( *getNo )( void ) = ( int( * ) () )_binary.findSymbol( "OfxGetNumberOfPlugins" ); 00022 OfxPlugin* ( *getPlug )(int) = ( OfxPlugin * ( * )( int ) )_binary.findSymbol( "OfxGetPlugin" ); 00023 00024 if( getNo == 0 || getPlug == 0 ) 00025 { 00026 _binary.setInvalid( true ); 00027 } 00028 else 00029 { 00030 int pluginCount = ( *getNo )( ); 00031 00032 _plugins.clear(); 00033 _plugins.reserve( pluginCount ); 00034 00035 for( int i = 0; i < pluginCount; ++i ) 00036 { 00037 OfxPlugin& plug = *( *getPlug )( i ); 00038 00039 APICache::OfxhPluginAPICacheI* api = cache->findApiHandler( plug.pluginApi, plug.apiVersion ); 00040 assert( api ); 00041 00042 OfxhPlugin* newPlug = api->newPlugin( *this, i, plug ); 00043 if( newPlug == NULL ) 00044 { 00045 BOOST_THROW_EXCEPTION( exception::Unknown() 00046 << exception::dev( "Error creating a new OfxhPlugin." ) 00047 << exception::pluginIdentifier( plug.pluginIdentifier ) 00048 << exception::ofxApi( plug.pluginApi ) 00049 << exception::filename( _binary.getBinaryPath() ) ); 00050 } 00051 _plugins.push_back( newPlug ); 00052 } 00053 } 00054 _binary.unload(); 00055 } 00056 00057 OfxhPluginBinary::~OfxhPluginBinary() 00058 {} 00059 00060 } 00061 } 00062 } 00063