#include <cpPlugins/Interface/Workspace.h>
-#include <tinyxml2/tinyxml2.h>
+#include <cpPlugins/tinyxml2/tinyxml2.h>
// -------------------------------------------------------------------------
void cpPlugins::Interface::Workspace::
Load( const std::string& fname )
{
this->Clear( );
- TInterface::Pointer interface = TInterface::New( );
// Read from disk
tinyxml2::XMLDocument* doc = new tinyxml2::XMLDocument( );
} // fi
- // Load plugins
- auto loaded_plugins = 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
- {
- 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 != "" )
- {
- delete doc;
- throw std::runtime_error(
- std::string( "cpPlugins::Workspace: " ) + plugins_errors
- );
-
- } // fi
-
// Read filters
std::stringstream err;
tinyxml2::XMLElement* filter = root->FirstChildElement( "Filter" );
);
if( class_value != NULL && name_value != NULL )
{
- auto new_filter =
- this->CreateFilter( category_value, class_value, name_value );
+ auto new_filter = this->CreateFilter( category_value, class_value );
if( new_filter != NULL )
{
+ this->RenameFilter( new_filter->GetName( ), name_value );
new_filter->SetViewCoords( viewX, viewY );
new_filter->SetExplicitExecution( explicit_execution == 1 );
new_filter->GetParameters( )->FromXML( filter );
{
try
{
- this->Connect( orig_filter, dest_filter, orig_name, dest_name );
+ this->Connect( orig_filter, orig_name, dest_filter, dest_name );
}
catch( std::exception& exc )
{
} // elihw
// Read exposed inputs
- tinyxml2::XMLElement* port = root->FirstChildElement( "ExposedInput" );
- while( port != NULL )
- {
- this->ExposeInput(
- port->Attribute( "Name" ),
- port->Attribute( "Filter" ),
- port->Attribute( "Input" )
- );
- port = port->NextSiblingElement( "ExposedInput" );
-
- } // elihw
-
- // Read exposed outputs
- port = root->FirstChildElement( "ExposedOutput" );
- while( port != NULL )
- {
- this->ExposeOutput(
- port->Attribute( "Name" ),
- port->Attribute( "Filter" ),
- port->Attribute( "Output" )
- );
- port = port->NextSiblingElement( "ExposedOutput" );
-
- } // elihw
+ /* TODO
+ tinyxml2::XMLElement* port = root->FirstChildElement( "ExposedInput" );
+ while( port != NULL )
+ {
+ this->ExposeInput(
+ port->Attribute( "Name" ),
+ port->Attribute( "Filter" ),
+ port->Attribute( "Input" )
+ );
+ port = port->NextSiblingElement( "ExposedInput" );
+
+ } // elihw
+
+ // Read exposed outputs
+ port = root->FirstChildElement( "ExposedOutput" );
+ while( port != NULL )
+ {
+ this->ExposeOutput(
+ port->Attribute( "Name" ),
+ port->Attribute( "Filter" ),
+ port->Attribute( "Output" )
+ );
+ port = port->NextSiblingElement( "ExposedOutput" );
+
+ } // elihw
+ */
// Throw errors
std::string err_str = err.str( );
} // 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 );
+ /* TODO
+ 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
for( auto i = this->m_Filters.begin( ); i != this->m_Filters.end( ); ++i )
} // rof
-
// Save exposed ports
- auto eipIt = this->m_ExposedInputs.begin( );
- for( ; eipIt != this->m_ExposedInputs.end( ); ++eipIt )
- {
- tinyxml2::XMLElement* port = doc->NewElement( "ExposedInput" );
- port->SetAttribute( "Name", eipIt->first.c_str( ) );
- port->SetAttribute( "Filter", eipIt->second.first.c_str( ) );
- port->SetAttribute( "Input", eipIt->second.second.c_str( ) );
- root->LinkEndChild( port );
-
- } // rof
-
- auto eopIt = this->m_ExposedOutputs.begin( );
- for( ; eopIt != this->m_ExposedOutputs.end( ); ++eopIt )
- {
- tinyxml2::XMLElement* port = doc->NewElement( "ExposedOutput" );
- port->SetAttribute( "Name", eopIt->first.c_str( ) );
- port->SetAttribute( "Filter", eopIt->second.first.c_str( ) );
- port->SetAttribute( "Output", eopIt->second.second.c_str( ) );
- root->LinkEndChild( port );
-
- } // rof
+ /* TODO
+ auto eipIt = this->m_ExposedInputs.begin( );
+ for( ; eipIt != this->m_ExposedInputs.end( ); ++eipIt )
+ {
+ tinyxml2::XMLElement* port = doc->NewElement( "ExposedInput" );
+ port->SetAttribute( "Name", eipIt->first.c_str( ) );
+ port->SetAttribute( "Filter", eipIt->second.first.c_str( ) );
+ port->SetAttribute( "Input", eipIt->second.second.c_str( ) );
+ root->LinkEndChild( port );
+
+ } // rof
+
+ auto eopIt = this->m_ExposedOutputs.begin( );
+ for( ; eopIt != this->m_ExposedOutputs.end( ); ++eopIt )
+ {
+ tinyxml2::XMLElement* port = doc->NewElement( "ExposedOutput" );
+ port->SetAttribute( "Name", eopIt->first.c_str( ) );
+ port->SetAttribute( "Filter", eopIt->second.first.c_str( ) );
+ port->SetAttribute( "Output", eopIt->second.second.c_str( ) );
+ root->LinkEndChild( port );
+
+ } // rof
+ */
// Physical write and return
doc->LinkEndChild( root );