Esempio n. 1
0
//=================================================================================
bool PluginManager::ProcessAllPlugins( PluginProcessor* pluginProcessor )
{
	for( PluginList::iterator iter = pluginList.begin(); iter != pluginList.end(); iter++ )
	{
		Plugin* plugin = *iter;
		if( !pluginProcessor->ProcessPlugin( plugin->GetEventHandler(), plugin->GetLibraryPath() ) )
			return false;
	}
	return true;
}
Esempio n. 2
0
//=================================================================================
bool PluginManager::LoadPlugin( const Cornucopia::Path& libraryPath )
{
	bool success = false;
	Plugin* plugin = 0;

	do
	{
		// Make sure that the plugin is not already loaded.
		if( FindPlugin( libraryPath ) )
		{
			wxMessageBox( wxString::Format( wxT( "The plugin \"%s\" is already loaded." ), ( const char* )libraryPath ), wxT( "Error" ), wxOK | wxCENTRE );
			break;
		}

		// Create a new plugin object to represent the plugin in our list.
		plugin = new ( std::nothrow ) Plugin();
		if( !plugin )
			break;

		// Attempt to load the plugin library.
		if( !plugin->Load( libraryPath ) )
			break;

		// Attempt to initialize the plugin.
		CornucopiaEditor::Plugin* eventHandler = plugin->GetEventHandler();
		if( !eventHandler->Initialize( &assistant ) )
		{
			wxMessageBox( wxString::Format( wxT( "The plugin \"%s\" failed to initialize." ), ( const char* )libraryPath ), wxT( "Error" ), wxOK | wxCENTRE );
			break;
		}

		// Send the first event to the plugin.
		PluginEvent event;
		event.SetEventObject(0);
		event.SetEventType( CORNUCOPIA_PLUGIN_INITIALIZE );
		( void )CallPlugin( plugin, event );

		// We made it threw the gauntlet!
		success = true;
	}
	while( false );

	// Discard or keep the plugin.
	if( !success )
		delete plugin;
	else
		pluginList.push_back( plugin );

	return success;
}
Esempio n. 3
0
//=================================================================================
bool PluginManager::UnloadPlugin( PluginList::iterator& iter )
{
	// Remove the plugin from our list.
	Plugin* plugin = *iter;
	pluginList.erase( iter );

	// Send the last event to the plugin.
	PluginEvent event;
	event.SetEventObject(0);
	event.SetEventType( CORNUCOPIA_PLUGIN_FINALIZE );
	( void )CallPlugin( plugin, event );

	// We can now dispose of the plugin.
	plugin->GetEventHandler()->Finalize( &assistant );
	plugin->Unload();
	delete plugin;
	return true;
}