]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Workspace.cxx
debug finished
[cpPlugins.git] / lib / cpPlugins / Interface / Workspace.cxx
index c56897e2b1cbc317f67b6397d2736d35fb42505e..5b80a36bb9a19f392bf941be9a7c9fd4f7cd3d90 100644 (file)
 #include <cpPlugins/Interface/Workspace.h>
-#include <cpPlugins/Interface/SimpleMPRWidget.h>
-#include <vtkRenderWindowInteractor.h>
+#include <cpPlugins/BaseObjects/Widget.h>
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Workspace::
-Workspace( )
-  : m_Plugins( NULL ),
-    m_MPRViewer( NULL )
+void cpPlugins::Interface::Workspace::
+Clear( )
 {
-  this->m_Graph = TGraph::New( );
+  this->m_Filters.clear( );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Workspace::
-~Workspace( )
+std::vector< std::string > cpPlugins::Interface::Workspace::
+GetFiltersNames( ) const
 {
+  std::vector< std::string > n;
+  for( auto i : this->m_Filters )
+    n.push_back( i.first );
+  return( n );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Workspace::
-TPlugins* cpPlugins::Interface::Workspace::
-GetPlugins( )
+TFilter* cpPlugins::Interface::Workspace::
+GetFilter( const std::string& name )
 {
-  return( this->m_Plugins );
+  auto i = this->m_Filters.find( name );
+  if( i != this->m_Filters.end( ) )
+    return( i->second.GetPointer( ) );
+  else
+    return( NULL );
 }
 
 // -------------------------------------------------------------------------
 const cpPlugins::Interface::Workspace::
-TPlugins* cpPlugins::Interface::Workspace::
-GetPlugins( ) const
-{
-  return( this->m_Plugins );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-SetPlugins( TPlugins* i )
+TFilter* cpPlugins::Interface::Workspace::
+GetFilter( const std::string& name ) const
 {
-  if( this->m_Plugins != i )
-    this->m_Plugins = i;
+  auto i = this->m_Filters.find( name );
+  if( i != this->m_Filters.end( ) )
+    return( i->second.GetPointer( ) );
+  else
+    return( NULL );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Workspace::
-TGraph* cpPlugins::Interface::Workspace::
-GetGraph( )
+TWidget* cpPlugins::Interface::Workspace::
+GetWidget( const std::string& name )
 {
-  return( this->m_Graph );
+  TFilter* process = this->GetFilter( name );
+  return( dynamic_cast< TWidget* >( process ) );
 }
 
 // -------------------------------------------------------------------------
 const cpPlugins::Interface::Workspace::
-TGraph* cpPlugins::Interface::Workspace::
-GetGraph( ) const
+TWidget* cpPlugins::Interface::Workspace::
+GetWidget( const std::string& name ) const
 {
-  return( this->m_Graph );
+  const TFilter* process = this->GetFilter( name );
+  return( dynamic_cast< const TWidget* >( process ) );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-Clear( )
+bool cpPlugins::Interface::Workspace::
+HasFilter( const std::string& name ) const
 {
-  if( this->m_Graph.IsNotNull( ) )
-    this->m_Graph->Clear( );
+  return( this->m_Filters.find( name ) != this->m_Filters.end( ) );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-ClearConnections( )
+bool cpPlugins::Interface::Workspace::
+HasWidget( const std::string& name ) const
 {
+  const TWidget* wdg = this->GetWidget( name );
+  return( wdg != NULL );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Workspace::
 TFilter* cpPlugins::Interface::Workspace::
-GetFilter( const std::string& name )
+CreateFilter( const std::string& category, const std::string& filter )
 {
-  TFilter* f =
-    dynamic_cast< TFilter* >(
-      this->m_Graph->GetVertex( name ).GetPointer( )
-      );
-  return( f );
-}
+  typedef cpPlugins::BaseObjects::Widget _TWidget;
 
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TFilter* cpPlugins::Interface::Workspace::
-GetFilter( const std::string& name ) const
-{
-  const TFilter* f =
-    dynamic_cast< const TFilter* >(
-      this->m_Graph->GetVertex( name ).GetPointer( )
-      );
-  return( f );
-}
+  TFilter::Pointer o = this->m_Plugins->CreateFilter( category, filter );
+  if( o.IsNotNull( ) )
+  {
+    // Choose a name
+    std::string name = filter;
+    while( this->GetFilter( name ) != NULL )
+      name += std::string( "_" );
+    o->SetPrintExecution( this->m_PrintExecution );
+    o->SetName( name );
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Workspace::
-HasFilter( const std::string& name ) const
-{
-  if( this->m_Graph->HasVertexIndex( name ) )
-    return( this->GetFilter( name ) != NULL );
-  else
-    return( false );
+    // Interactors
+    for(
+      auto i = this->m_Interactors.begin( );
+      i != this->m_Interactors.end( );
+      ++i
+      )
+      o->AddInteractor( *i );
+
+    // Finish association
+    this->m_Filters[ name ] = o;
+
+  } // fi
+  return( o.GetPointer( ) );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Workspace::
-TFilter* cpPlugins::Interface::Workspace::
-CreateFilter( const std::string& filter, const std::string& name )
+bool cpPlugins::Interface::Workspace::
+RenameFilter( const std::string& old_name, const std::string& new_name )
 {
-  if( this->m_Plugins == NULL )
-    return( NULL );
-
-  // Get or create new filter from name
-  if( !( this->m_Graph->HasVertexIndex( name ) ) )
+  auto o = this->m_Filters.find( old_name );
+  auto n = this->m_Filters.find( new_name );
+  if( o != this->m_Filters.end( ) && n == this->m_Filters.end( ) )
   {
-    TFilter::Pointer f = this->m_Plugins->CreateObject( filter );
-    if( f.IsNotNull( ) )
-    {
-      f->SetName( name );
-      f->SetSingleInteractor( this->m_SingleInteractor );
-      f->SetMPRViewer( this->m_MPRViewer );
-      
-      TObject::Pointer o = f.GetPointer( );
-      this->m_Graph->SetVertex( name, o );
+    // Rename filter
+    o->second->SetName( new_name );
+    this->m_Filters[ new_name ] = o->second;
+    this->m_Filters.erase( o );
+
+    // Rename exposed ports
+    /* TODO
+       auto e = this->m_ExposedInputs.begin( );
+       for( ; e != this->m_ExposedInputs.end( ); ++e )
+       if( e->second.first == old_name )
+       e->second.first = new_name;
+       e = this->m_ExposedOutputs.begin( );
+       for( ; e != this->m_ExposedOutputs.end( ); ++e )
+       if( e->second.first == old_name )
+       e->second.first = new_name;
+    */
 
-    } // fi
-    return( f.GetPointer( ) );
+    return( true );
   }
   else
-    return( this->GetFilter( name ) );
+    return( false );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
-RenameFilter( const std::string& old_name, const std::string& new_name )
+RemoveFilter( const std::string& name )
 {
-  if( this->m_Graph->RenameVertex( old_name, new_name ) )
+  auto i = this->m_Filters.find( name );
+  if( i != this->m_Filters.end( ) )
   {
-    TFilter* f = this->GetFilter( new_name );
-    f->SetName( new_name );
+    i->second->Disconnect( );
+    this->m_Filters.erase( i );
     return( true );
   }
   else
@@ -149,160 +155,283 @@ RenameFilter( const std::string& old_name, const std::string& new_name )
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
-RemoveFilter( const std::string& name )
+SetPrintExecution( bool b )
 {
+  this->m_PrintExecution = b;
+  for( auto i = this->m_Filters.begin( ); i != this->m_Filters.end( ); ++i )
+    i->second->SetPrintExecution( b );
 }
 
 // -------------------------------------------------------------------------
-vtkRenderWindowInteractor* cpPlugins::Interface::Workspace::
-GetSingleInteractor( )
+void cpPlugins::Interface::Workspace::
+PrintExecutionOn( )
 {
-  return( this->m_SingleInteractor );
+  this->SetPrintExecution( true );
 }
 
 // -------------------------------------------------------------------------
-const vtkRenderWindowInteractor* cpPlugins::Interface::Workspace::
-GetSingleInteractor( ) const
+void cpPlugins::Interface::Workspace::
+PrintExecutionOff( )
 {
-  return( this->m_SingleInteractor );
+  this->SetPrintExecution( true );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
-SetSingleInteractor( vtkRenderWindowInteractor* interactor )
+AddInteractor( vtkRenderWindowInteractor* iren )
 {
-  this->m_SingleInteractor = interactor;
-}
+  if( iren != NULL )
+  {
+    this->m_Interactors.insert( iren );
+    for( auto f : this->m_Filters )
+      f.second->AddInteractor( iren );
 
-// -------------------------------------------------------------------------
-cpPlugins::Interface::
-SimpleMPRWidget* cpPlugins::Interface::Workspace::
-GetMPRViewer( )
-{
-  return( this->m_MPRViewer );
+  } // fi
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::
-SimpleMPRWidget* cpPlugins::Interface::Workspace::
-GetMPRViewer( ) const
+bool cpPlugins::Interface::Workspace::
+Connect(
+  const std::string& origin_filter,
+  const std::string& origin_output,
+  const std::string& destination_filter,
+  const std::string& destination_input
+  )
 {
-  return( this->m_MPRViewer );
-}
+  // Get filters and check pertinence
+  TFilter* origin = this->GetFilter( origin_filter );
+  TFilter* destination = this->GetFilter( destination_filter );
+  if( origin == NULL || destination == NULL )
+    return( false );
+  if( !( destination->HasInput( destination_input ) ) )
+    return( false );
+  if( !( origin->HasOutput( origin_output ) ) )
+    return( false );
 
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
-{
-  this->m_MPRViewer = wdg;
+  // Check if there is room for a new connection
+  bool ok = true;
+  if( destination->IsInputMultiple( destination_input ) )
+  {
+    for(
+      unsigned int i = 0;
+      i < destination->GetInputSize( destination_input );
+      ++i
+      )
+      if(
+        destination->GetInput( destination_input, i )->GetSource( ) == origin
+        )
+        ok = false;
+  }
+  else
+    ok = ( destination->GetInput( destination_input ) == NULL );
+  if( ok )
+    destination->AddInput(
+      destination_input,
+      origin->GetOutput( origin_output )
+      );
+  return( ok );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
 Connect(
-  const std::string& orig_filter, const std::string& dest_filter,
-  const std::string& output_name, const std::string& input_name
+  TDataObject* input,
+  const std::string& destination_filter,
+  const std::string& destination_input
   )
 {
-  // Get filters
-  TFilter* orig = this->GetFilter( orig_filter );
-  TFilter* dest = this->GetFilter( dest_filter );
-  if( orig == NULL || dest == NULL )
+  // Get filters and check pertinence
+  if( input == NULL )
+    return( false );
+  TFilter* destination = this->GetFilter( destination_filter );
+  if( destination == NULL )
+    return( false );
+  if( !( destination->HasInput( destination_input ) ) )
     return( false );
 
-  // Real connection
-  if( dest->SetInput( input_name, orig->GetOutput( output_name ) ) )
+  // Check if there is room for a new connection
+  bool ok = true;
+  if( destination->IsInputMultiple( destination_input ) )
   {
-    this->m_Graph->AddEdge(
-      orig_filter, dest_filter,
-      TConnection( output_name, input_name )
-      );
-    return( true );
+    for(
+      unsigned int i = 0;
+      i < destination->GetInputSize( destination_input );
+      ++i
+      )
+      if(
+        destination->GetInput( destination_input, i )->GetSource( ) ==
+        input->GetSource( )
+        )
+        ok = false;
   }
   else
-    return( false );
+    ok = ( destination->GetInput( destination_input ) == NULL );
+  if( ok )
+    destination->AddInput(
+      destination_input,
+      input
+      );
+  return( ok );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
-Connect(
-  const ProcessObjectPort& input_port, const std::string& exposed_port
+Disconnect(
+  const std::string& origin_filter,
+  const std::string& origin_output,
+  const std::string& destination_filter,
+  const std::string& destination_input
   )
 {
-  auto port = this->m_ExposedInputPorts.find( exposed_port );
-  if( port != this->m_ExposedInputPorts.end( ) )
+  // Get filters and check pertinence
+  TFilter* origin = this->GetFilter( origin_filter );
+  TFilter* destination = this->GetFilter( destination_filter );
+  if( origin == NULL || destination == NULL )
+    return( false );
+  if( !( destination->HasInput( destination_input ) ) )
+    return( false );
+  if( !( origin->HasOutput( origin_output ) ) )
+    return( false );
+
+  // Check if there is room for a new connection
+  bool ok = false;
+  unsigned int del_id = 0;
+  for(
+    unsigned int i = 0;
+    i < destination->GetInputSize( destination_input );
+    ++i
+    )
+    if(
+      destination->GetInput( destination_input, i )->GetSource( ) == origin
+      )
+    {
+      ok = true;
+      del_id = i;
+
+    } // fi
+  if( ok )
+    destination->DisconnectInput( destination_input, del_id );
+  return( ok );
+}
+
+// -------------------------------------------------------------------------
+/*
+const cpPlugins::Interface::Workspace::
+TExposedPorts& cpPlugins::Interface::Workspace::
+GetExposedInputs( ) const
+{
+  return( this->m_ExposedInputs );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Workspace::
+TExposedPorts& cpPlugins::Interface::Workspace::
+GetExposedOutputs( ) const
+{
+  return( this->m_ExposedOutputs );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BaseObjects::DataObject* cpPlugins::Interface::Workspace::
+GetExposedOutput( const std::string& name )
+{
+  auto i = this->m_ExposedOutputs.find( name );
+  if( i != this->m_ExposedOutputs.end( ) )
   {
-    TFilter* filter = this->GetFilter( port->second.first );
-    if( filter != NULL )
-      return( filter->SetInput( port->second.second, input_port ) );
+    auto f = this->GetFilter( i->second.first );
+    if( f != NULL )
+      return( f->GetOutput( i->second.second ) );
     else
-      return( false );
+      return( NULL );
   }
   else
-    return( false );
+    return( NULL );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Workspace::
-Reduce( const std::string& name )
+const cpPlugins::BaseObjects::DataObject* cpPlugins::Interface::Workspace::
+GetExposedOutput( const std::string& name ) const
 {
-  return( false );
+  auto i = this->m_ExposedOutputs.find( name );
+  if( i != this->m_ExposedOutputs.end( ) )
+  {
+    auto f = this->GetFilter( i->second.first );
+    if( f != NULL )
+      return( f->GetOutput( i->second.second ) );
+    else
+      return( NULL );
+  }
+  else
+    return( NULL );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-ExposeInputPort(
+bool cpPlugins::Interface::Workspace::
+ExposeInput(
   const std::string& name,
   const std::string& filter, const std::string& filter_input
   )
 {
-  this->m_ExposedInputPorts[ name ] = TExposedPort( filter, filter_input );
+  auto i = this->m_ExposedInputs.find( name );
+  if( i == this->m_ExposedInputs.end( ) )
+  {
+    this->m_ExposedInputs[ name ] =
+      std::pair< std::string, std::string >( filter, filter_input );
+    return( true );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-ExposeOutputPort(
+bool cpPlugins::Interface::Workspace::
+ExposeOutput(
   const std::string& name,
   const std::string& filter, const std::string& filter_output
   )
 {
-  this->m_ExposedOutputPorts[ name ] = TExposedPort( filter, filter_output );
+  auto i = this->m_ExposedOutputs.find( name );
+  if( i == this->m_ExposedOutputs.end( ) )
+  {
+    this->m_ExposedOutputs[ name ] =
+      std::pair< std::string, std::string >( filter, filter_output );
+    return( true );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
-HideInputPort( const std::string& name )
+HideInput( const std::string& name )
 {
-  auto i = this->m_ExposedInputPorts.find( name );
-  if( i != this->m_ExposedInputPorts.end( ) )
-    this->m_ExposedInputPorts.erase( i );
+  auto i = this->m_ExposedInputs.find( name );
+  if( i != this->m_ExposedInputs.end( ) )
+    this->m_ExposedInputs.erase( i );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Workspace::
-HideOutputPort( const std::string& name )
+HideOutput( const std::string& name )
 {
-  auto i = this->m_ExposedOutputPorts.find( name );
-  if( i != this->m_ExposedOutputPorts.end( ) )
-    this->m_ExposedOutputPorts.erase( i );
+  auto i = this->m_ExposedOutputs.find( name );
+  if( i != this->m_ExposedOutputs.end( ) )
+    this->m_ExposedOutputs.erase( i );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
-RenameExposedInputPort(
-  const std::string& old_name,
-  const std::string& new_name
+RenameExposedInput(
+  const std::string& old_name, const std::string& new_name
   )
 {
-  auto o = this->m_ExposedInputPorts.find( old_name );
-  auto n = this->m_ExposedInputPorts.find( new_name );
-  if(
-    o != this->m_ExposedInputPorts.end( ) &&
-    n == this->m_ExposedInputPorts.end( )
-    )
+  auto o = this->m_ExposedInputs.find( old_name );
+  auto n = this->m_ExposedInputs.find( new_name );
+  if( o != this->m_ExposedInputs.end( ) && n == this->m_ExposedInputs.end( ) )
   {
-    this->m_ExposedInputPorts[ new_name ] = o->second;
-    this->m_ExposedInputPorts.erase( o );
+    this->m_ExposedInputs[ new_name ] = o->second;
+    this->m_ExposedInputs.erase( o );
+    return( true );
   }
   else
     return( false );
@@ -310,74 +439,190 @@ RenameExposedInputPort(
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Workspace::
-RenameExposedOutputPort(
-  const std::string& old_name,
-  const std::string& new_name
+RenameExposedOutput(
+  const std::string& old_name, const std::string& new_name
   )
 {
-  auto o = this->m_ExposedOutputPorts.find( old_name );
-  auto n = this->m_ExposedOutputPorts.find( new_name );
+  auto o = this->m_ExposedOutputs.find( old_name );
+  auto n = this->m_ExposedOutputs.find( new_name );
   if(
-    o != this->m_ExposedOutputPorts.end( ) &&
-    n == this->m_ExposedOutputPorts.end( )
+    o != this->m_ExposedOutputs.end( ) && n == this->m_ExposedOutputs.end( )
     )
   {
-    this->m_ExposedOutputPorts[ new_name ] = o->second;
-    this->m_ExposedOutputPorts.erase( o );
+    this->m_ExposedOutputs[ new_name ] = o->second;
+    this->m_ExposedOutputs.erase( o );
+    return( true );
   }
   else
     return( false );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TExposedPorts& cpPlugins::Interface::Workspace::
-GetExposedInputPorts( ) const
+std::vector< std::pair< std::string, std::string > >
+cpPlugins::Interface::Workspace::
+GetConnections(
+  const std::string& origin, const std::string& destination
+  ) const
+{
+  std::vector< std::pair< std::string, std::string > > conns;
+  auto orig = this->GetFilter( origin );
+  auto dest = this->GetFilter( destination );
+  if( orig != NULL && dest != NULL )
+  {
+    auto outs = orig->GetOutputsNames( );
+    auto ins = dest->GetInputsNames( );
+    for( auto o = outs.begin( ); o != outs.end( ); ++o )
+    {
+      for( auto i = ins.begin( ); i != ins.end( ); ++i )
+      {
+        unsigned int nInputs = dest->GetInputSize( *i );
+        for( unsigned j = 0; j < nInputs; ++j )
+        {
+          auto od = orig->GetOutput( *o );
+          auto id = dest->GetInput( *i, j );
+          if( od != NULL && od == id )
+            conns.push_back(
+              std::pair< std::string, std::string >( *o, *i )
+              );
+
+        } // rof
+
+      } // rof
+
+    } // rof
+
+  } // fi
+  return( conns );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+Connect(
+  const std::string& orig_filter, const std::string& dest_filter,
+  const std::string& output_name, const std::string& input_name
+  )
 {
-  return( this->m_ExposedInputPorts );
+  auto o = this->GetFilter( orig_filter );
+  auto d = this->GetFilter( dest_filter );
+  if( o != NULL && d != NULL )
+  {
+    try
+    {
+      d->AddInput( input_name, o->GetOutput( output_name ) );
+    }
+    catch( std::exception& err )
+    {
+      throw std::logic_error(
+        std::string( "Error connecting \"" ) +
+        output_name + std::string( "@" ) + orig_filter +
+        std::string( "\" with \"" ) +
+        input_name + std::string( "@" ) + dest_filter +
+        std::string( "\": " ) +
+        err.what( )
+        );
+
+    } // yrt
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TExposedPorts& cpPlugins::Interface::Workspace::
-GetExposedOutputPorts( ) const
+void cpPlugins::Interface::Workspace::
+Connect(
+  cpPlugins::BaseObjects::DataObject* output,
+  const std::string& dest_filter, const std::string& input_name
+  )
 {
-  return( this->m_ExposedOutputPorts );
+  auto d = this->GetFilter( dest_filter );
+  if( d != NULL )
+    d->AddInput( input_name, output );
 }
 
 // -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Workspace::
-Execute( )
+void cpPlugins::Interface::Workspace::
+Connect(
+  cpPlugins::BaseObjects::DataObject* output,
+  const std::string& exposed_input_name
+  )
 {
-  // Find sinks
-  std::set< std::string > sinks = this->m_Graph->GetSinks( );
+  auto i = this->m_ExposedInputs.find( exposed_input_name );
+  if( i != this->m_ExposedInputs.end( ) )
+    this->Connect( output, i->second.first, i->second.second );
+}
 
-  // Update sinks
-  std::string err = "";
-  for( auto sIt = sinks.begin( ); sIt != sinks.end( ); ++sIt )
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+Disconnect(
+  const std::string& orig_filter, const std::string& dest_filter,
+  const std::string& output_name, const std::string& input_name
+  )
+{
+  auto orig = this->GetFilter( orig_filter );
+  auto dest = this->GetFilter( dest_filter );
+  if( orig != NULL && dest != NULL )
   {
-    std::string lerr = this->Execute( *sIt );
-    if( lerr != "" )
-      err += lerr + std::string( "\n" );
+    auto out = orig->GetOutput( output_name );
+    auto in = dest->GetInput( input_name );
+    if( out != NULL && out == in )
+      dest->SetInput(
+        input_name, ( cpPlugins::BaseObjects::DataObject* )( NULL )
+        );
 
-  } // rof
-  return( err );
+  } // fi
 }
 
 // -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Workspace::
-Execute( const std::string& name )
+void cpPlugins::Interface::Workspace::
+Disconnect(
+  const std::string& dest_filter, const std::string& input_name
+  )
 {
-  // Get filter
-  TFilter* f = this->GetFilter( name );
-  if( f == NULL )
-    return(
-      std::string( "cpPlugins::Interface::Workspace: Vertex \"" ) +
-      name + std::string( "\" is not a filter." )
-      );
+  throw std::logic_error( "Disconnect 1" );
+}
 
-  // Execute and return
-  return( f->Update( ) );
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+Disconnect( const std::string& dest_filter )
+{
+  throw std::logic_error( "Disconnect 2" );
+}
+*/
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+Update( )
+{
+  for( auto f = this->m_Filters.begin( ); f != this->m_Filters.end( ); ++f )
+    f->second->Update( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+Update( const std::string& name )
+{
+  auto filter = this->GetFilter( name );
+  if( filter != NULL )
+    filter->Update( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+Workspace( )
+  : Superclass( ),
+    m_PrintExecution( false )
+{
+  this->m_Plugins = TPlugins::New( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+~Workspace( )
+{
+  /* TODO
+     this->m_ExposedOutputs.clear( );
+     this->m_ExposedInputs.clear( );
+  */
+  this->m_Filters.clear( );
 }
 
 // eof - $RCSfile$