std::string cpPlugins::Workspace::
LoadWorkspace( const std::string& fname )
{
+ if( this->m_Interface == NULL )
+ return( "cpPlugins::Workspace: No valid plugins interface" );
tinyxml2::XMLDocument* doc = new tinyxml2::XMLDocument( );
doc->LoadFile( fname.c_str( ) );
tinyxml2::XMLElement* root = doc->RootElement( );
return( "cpPlugins::Workspace: No valid workspace" );
std::stringstream err;
+ // Load plugins
+ auto loaded_plugins = this->m_Interface->GetPlugins( );
+ tinyxml2::XMLElement* plugins = root->FirstChildElement( "plugins" );
+ std::string plugins_errors = "";
+ while( plugins != NULL )
+ {
+ tinyxml2::XMLElement* plugin = plugins->FirstChildElement( "plugin" );
+ while( plugin != NULL )
+ {
+ std::string name = plugin->Attribute( "name" );
+ if( loaded_plugins.find( name ) == loaded_plugins.end( ) )
+ {
+ try
+ {
+ this->m_Interface->LoadPlugin( name );
+ }
+ catch( std::exception& err )
+ {
+ plugins_errors += err.what( ) + std::string( "\n" );
+
+ } // yrt
+
+ } // fi
+ plugin = plugin->NextSiblingElement( "plugin" );
+
+ } // elihw
+ plugins = plugins->NextSiblingElement( "plugins" );
+
+ } // elihw
+ if( plugins_errors != "" )
+ return( std::string( "cpPlugins::Workspace: " ) + plugins_errors );
+
// Read filters
tinyxml2::XMLElement* filter = root->FirstChildElement( "filter" );
while( filter != NULL )
std::stringstream err;
tinyxml2::XMLDocument* doc = new tinyxml2::XMLDocument( );
tinyxml2::XMLElement* root = doc->NewElement( "cpPlugins_Workspace" );
+ std::set< std::string > used_plugins;
// Save vertices
auto vIt = this->m_Graph->BeginVertices( );
auto data = dynamic_cast< DataObject* >( vIt->second.GetPointer( ) );
if( filter != NULL )
{
+ used_plugins.insert( this->m_Interface->GetPluginName( filter ) );
+
tinyxml2::XMLElement* e = doc->NewElement( "filter" );
e->SetAttribute( "category", filter->GetClassCategory( ) );
e->SetAttribute( "class", filter->GetClassName( ) );
} // rof
+ // Save used plugins
+ tinyxml2::XMLElement* plugins = doc->NewElement( "plugins" );
+ for( auto pIt = used_plugins.begin( ); pIt != used_plugins.end( ); ++pIt )
+ {
+ tinyxml2::XMLElement* e = doc->NewElement( "plugin" );
+ e->SetAttribute( "name", pIt->c_str( ) );
+ plugins->LinkEndChild( e );
+
+ } // rof
+ root->LinkEndChild( plugins );
+
// Save connections
auto mIt = this->m_Graph->BeginEdgesRows( );
for( ; mIt != this->m_Graph->EndEdgesRows( ); ++mIt )