]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/BaseObjects/Port.cxx
...
[cpPlugins.git] / lib / cpPlugins / BaseObjects / Port.cxx
index 06b10ee097a2d6100eecabec1d79bf80539e2dea..6236ae1fcd447c702b455df51371e333e3452be0 100644 (file)
@@ -149,19 +149,25 @@ cpPlugins::BaseObjects::MultipleInputsPort::
 void cpPlugins::BaseObjects::MultipleInputsPort::
 Add( cpPlugins::BaseObjects::DataObject* o )
 {
-  /* TODO
-     if( o == NULL )
-     return;
-     auto otype = std::type_index( typeid( *o ) );
-     if( this->m_Type == otype )
-     this->m_Data.push_back( o );
-     else
-     throw std::logic_error(
-     "cpPlugins::MultipleInputsPort: incompatible types \"" +
-     std::string( otype.name( ) ) + std::string( "\" and \"" ) +
-     std::string( this->m_Type.name( ) ) + std::string( "\"" )
-     );
-  */
+  if( this->m_Sample.IsNull( ) )
+    throw std::logic_error(
+      "cpPlugins::SingleDataPort: Port not yet configured"
+      );
+  if( o != NULL )
+  {
+    if( this->m_Sample->IsCompatible( o ) )
+    {
+      this->m_Data.push_back( o );
+    }
+    else
+      throw std::logic_error(
+        "cpPlugins::SingleDataPort: incompatible types \"" +
+        std::string( typeid( *o ).name( ) ) + std::string( "\" and \"" ) +
+        std::string( typeid( *( this->m_Sample.GetPointer( ) ) ).name( ) ) +
+        std::string( "\"" )
+        );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------