]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/WorkspaceIO.cxx
More on graph editor
[cpPlugins.git] / lib / cpPlugins / Interface / WorkspaceIO.cxx
index 0651011389400e09b01604fc174c82d9275e1125..e14a44ef7e4c94ee1e286128dcd9c8dd37ebd614 100644 (file)
@@ -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$