X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcpPlugins%2FInterface%2FWorkspaceIO.cxx;h=e14a44ef7e4c94ee1e286128dcd9c8dd37ebd614;hb=ef8b6e12859181d3faa8019ce7319c539c0f86ec;hp=0651011389400e09b01604fc174c82d9275e1125;hpb=49ccd98bd1a735c6cf787853addb4ff2a2bfd2e1;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/WorkspaceIO.cxx b/lib/cpPlugins/Interface/WorkspaceIO.cxx index 0651011..e14a44e 100644 --- a/lib/cpPlugins/Interface/WorkspaceIO.cxx +++ b/lib/cpPlugins/Interface/WorkspaceIO.cxx @@ -8,6 +8,8 @@ LoadWorkspace( const std::string& fname ) TiXmlDocument* doc = new TiXmlDocument( fname.c_str( ) ); doc->LoadFile( ); TiXmlElement* root = doc->RootElement( ); + if( root == NULL ) + return( "cpPlugins::Interface::Workspace: No valid file" ); if( std::string( root->Value( ) ) != "cpPlugins_Workspace" ) return( "cpPlugins::Interface::Workspace: No valid workspace" ); std::stringstream err; @@ -233,7 +235,43 @@ LoadWorkspace( const std::string& fname ) std::string cpPlugins::Interface::Workspace:: SaveWorkspace( const std::string& fname ) const { - return( "" ); + std::stringstream err; + TiXmlDocument* doc = new TiXmlDocument( ); + TiXmlElement* root = new TiXmlElement( "cpPlugins_Workspace" ); + + // Save plugins + for( + auto plugIt = this->m_LoadedPlugins.begin( ); + plugIt != this->m_LoadedPlugins.end( ); + ++plugIt + ) + { + TiXmlElement* plugin = new TiXmlElement( "plugins" ); + plugin->SetAttribute( "filename", plugIt->c_str( ) ); + root->LinkEndChild( plugin ); + + } // rof + + // Save vertices + auto vIt = this->m_Graph->BeginVertices( ); + for( ; vIt != this->m_Graph->EndVertices( ); ++vIt ) + { + auto filter = dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ); + auto data = dynamic_cast< TData* >( vIt->second.GetPointer( ) ); + if( filter != NULL ) + { + } + else if( data != NULL ) + { + } // fi + + } // rof + + // Physical write and return + doc->LinkEndChild( root ); + doc->SaveFile( fname.c_str( ) ); + delete doc; + return( err.str( ) ); } // eof - $RCSfile$