X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FWorkspaceIO.cxx;h=f811a5e9b6f57640e0ac9bdf196266e818df2e07;hb=6ffc11d77924d6ab7e94db95d41105982ac73e00;hp=7e7a2bd5b63423ac9e7b114b04658a03850a7bba;hpb=e3dc1dcc5279b279f0ed7e39ed87b902bab7778c;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/WorkspaceIO.cxx b/lib/cpPlugins/Interface/WorkspaceIO.cxx index 7e7a2bd..f811a5e 100644 --- a/lib/cpPlugins/Interface/WorkspaceIO.cxx +++ b/lib/cpPlugins/Interface/WorkspaceIO.cxx @@ -32,61 +32,7 @@ LoadWorkspace( const std::string& fname ) // Read parameters TParameters* parameters = new_filter->GetParameters( ); - parameters->Clear( ); - - TiXmlElement* param = filter->FirstChildElement( "parameter" ); - while( param != NULL ) - { - const char* param_name = param->Attribute( "name" ); - const char* param_type = param->Attribute( "type" ); - if( param_name != NULL && param_type != NULL ) - { - std::string param_type_str( param_type ); - const char* value = param->Attribute( "value" ); - if( value != NULL ) - { - if( param_type_str == "String" ) - parameters->ConfigureAsString( param_name ); - else if( param_type_str == "Bool" ) - parameters->ConfigureAsBool( param_name ); - else if( param_type_str == "Int" ) - parameters->ConfigureAsInt( param_name ); - else if( param_type_str == "Uint" ) - parameters->ConfigureAsUint( param_name ); - else if( param_type_str == "Real" ) - parameters->ConfigureAsReal( param_name ); - else if( param_type_str == "Index" ) - parameters->ConfigureAsIndex( param_name ); - else if( param_type_str == "Point" ) - parameters->ConfigureAsPoint( param_name ); - else if( param_type_str == "Vector" ) - parameters->ConfigureAsVector( param_name ); - else if( param_type_str == "StringList" ) - parameters->ConfigureAsStringList( param_name ); - else if( param_type_str == "BoolList" ) - parameters->ConfigureAsBoolList( param_name ); - else if( param_type_str == "IntList" ) - parameters->ConfigureAsIntList( param_name ); - else if( param_type_str == "UintList" ) - parameters->ConfigureAsUintList( param_name ); - else if( param_type_str == "RealList" ) - parameters->ConfigureAsRealList( param_name ); - else if( param_type_str == "IndexList" ) - parameters->ConfigureAsIndexList( param_name ); - else if( param_type_str == "PointList" ) - parameters->ConfigureAsPointList( param_name ); - else if( param_type_str == "VectorList" ) - parameters->ConfigureAsVectorList( param_name ); - else if( param_type_str == "Choices" ) - parameters->ConfigureAsChoices( param_name ); - parameters->SetString( param_name, value, false ); - - } // fi - - } // fi - param = param->NextSiblingElement( "parameter" ); - - } // elihw + parameters->FromXML( filter ); } else err @@ -122,6 +68,32 @@ LoadWorkspace( const std::string& fname ) } // elihw + // Read exposed inputs + TiXmlElement* port = root->FirstChildElement( "exposed_input_port" ); + while( port != NULL ) + { + this->ExposeInputPort( + port->Attribute( "port_name" ), + port->Attribute( "filter" ), + port->Attribute( "filter_port_name" ) + ); + port = port->NextSiblingElement( "exposed_input_port" ); + + } // elihw + + // Read exposed outputs + port = root->FirstChildElement( "exposed_output_port" ); + while( port != NULL ) + { + this->ExposeOutputPort( + port->Attribute( "port_name" ), + port->Attribute( "filter" ), + port->Attribute( "filter_port_name" ) + ); + port = port->NextSiblingElement( "exposed_output_port" ); + + } // elihw + // Finish and return delete doc; return( err.str( ) ); @@ -145,57 +117,13 @@ SaveWorkspace( const std::string& fname ) const { TiXmlElement* e = new TiXmlElement( "filter" ); e->SetAttribute( "class", filter->GetClassName( ) ); - e->SetAttribute( "name", filter->GetName( ) ); + e->SetAttribute( "name", vIt->first.c_str( ) ); e->SetAttribute( "ViewX", filter->GetViewX( ) ); e->SetAttribute( "ViewY", filter->GetViewY( ) ); const TParameters* params = filter->GetParameters( ); - std::vector< std::string > names; - params->GetNames( names ); - for( auto nIt = names.begin( ); nIt != names.end( ); ++nIt ) - { - TiXmlElement* p = new TiXmlElement( "parameter" ); - p->SetAttribute( "name", nIt->c_str( ) ); - if( params->HasString( *nIt ) ) - p->SetAttribute( "type", "String" ); - else if( params->HasBool( *nIt ) ) - p->SetAttribute( "type", "Bool" ); - else if( params->HasInt( *nIt ) ) - p->SetAttribute( "type", "Int" ); - else if( params->HasUint( *nIt ) ) - p->SetAttribute( "type", "Uint" ); - else if( params->HasReal( *nIt ) ) - p->SetAttribute( "type", "Real" ); - else if( params->HasIndex( *nIt ) ) - p->SetAttribute( "type", "Index" ); - else if( params->HasPoint( *nIt ) ) - p->SetAttribute( "type", "Point" ); - else if( params->HasVector( *nIt ) ) - p->SetAttribute( "type", "Vector" ); - else if( params->HasStringList( *nIt ) ) - p->SetAttribute( "type", "StringList" ); - else if( params->HasBoolList( *nIt ) ) - p->SetAttribute( "type", "BoolList" ); - else if( params->HasIntList( *nIt ) ) - p->SetAttribute( "type", "IntList" ); - else if( params->HasUintList( *nIt ) ) - p->SetAttribute( "type", "UintList" ); - else if( params->HasRealList( *nIt ) ) - p->SetAttribute( "type", "RealList" ); - else if( params->HasIndexList( *nIt ) ) - p->SetAttribute( "type", "IndexList" ); - else if( params->HasPointList( *nIt ) ) - p->SetAttribute( "type", "PointList" ); - else if( params->HasVectorList( *nIt ) ) - p->SetAttribute( "type", "VectorList" ); - else if( params->HasChoices( *nIt ) ) - p->SetAttribute( "type", "Choices" ); - p->SetAttribute( - "value", params->GetString( *nIt, false ).c_str( ) - ); - e->LinkEndChild( p ); + params->ToXML( e ); - } // rof root->LinkEndChild( e ); } else if( data != NULL ) @@ -233,6 +161,29 @@ SaveWorkspace( const std::string& fname ) const } // rof + // Save exposed ports + auto eipIt = this->m_ExposedInputPorts.begin( ); + for( ; eipIt != this->m_ExposedInputPorts.end( ); ++eipIt ) + { + TiXmlElement* port = new TiXmlElement( "exposed_input_port" ); + port->SetAttribute( "port_name", eipIt->first.c_str( ) ); + port->SetAttribute( "filter", eipIt->second.first.c_str( ) ); + port->SetAttribute( "filter_port_name", eipIt->second.second.c_str( ) ); + root->LinkEndChild( port ); + + } // rof + + auto eopIt = this->m_ExposedOutputPorts.begin( ); + for( ; eopIt != this->m_ExposedOutputPorts.end( ); ++eopIt ) + { + TiXmlElement* port = new TiXmlElement( "exposed_output_port" ); + port->SetAttribute( "port_name", eopIt->first.c_str( ) ); + port->SetAttribute( "filter", eopIt->second.first.c_str( ) ); + port->SetAttribute( "filter_port_name", eopIt->second.second.c_str( ) ); + root->LinkEndChild( port ); + + } // rof + // Physical write and return doc->LinkEndChild( root ); doc->SaveFile( fname.c_str( ) );