]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/GraphEditor/DataFlowEditor_OutNode.cxx
Salome HOME
Bug fix: don't set "Loading" state for MacroNodes in InitialState() function (called...
[modules/superv.git] / src / GraphEditor / DataFlowEditor_OutNode.cxx
index 0b4f09df7b7e0ff481479679482c6f6bf1211c8e..80add3a944878ff7dba6008690426da019bb86d3 100644 (file)
@@ -1008,6 +1008,11 @@ bool GraphEditor::OutNode::Executable() {
     StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
   }
 
+  // asv : 13.12.04 : introducing check for compatibility of linked ports' types.
+  if ( !IsLinksCompatible() ) {
+    _Executable = false;
+  }    
+
   cdebug_out << "GraphEditor::OutNode::Executable" << endl;
   return _Executable ;
 }
@@ -1673,7 +1678,43 @@ bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
   return true ;
 }
 
+/** Iterate through ALL links (OutPort-InPort pairs) and check if their types are 
+ *  compatible - call GraphEditor::DataFlow::IsCompatible(type1, type2).
+ *  Returns true if all are compatible.
+ */
+bool GraphEditor::OutNode::IsLinksCompatible() {
+  const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
+  bool b = true;
+  for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) {
+    GraphBase::SLink aLink = (*Links)[i];
+    GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() );
+    GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() );
+    const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() );
+    const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() );    
+    b = IsCompatible( anOutPort->PortType(), anInPort->PortType() );
+    cdebug << "GraphEditor::OutNode::IsLinksCompatible:  "<<aLink.FromNodeName << "("<<aLink.FromServiceParameterName
+      <<")  -->  "<<aLink.ToNodeName<<"("<<aLink.ToServiceParameterName<<") = " << (b ? "OK" : "Not compatible (ERROR)") << endl;
+    if ( !b )
+      MESSAGE( "Graph structure ERROR: type of port \""<<aLink.FromServiceParameterName<<"\" of node \""
+             <<aLink.FromNodeName<<"\" is not compatible with type of linked port \""
+             <<aLink.ToServiceParameterName<<"\" of node \""<<aLink.ToNodeName<<"\"" );
+  }
+  return b;
+}
 
+/**Returns true if an out-port of type "OutPortType" can be bound with in-port of type "InPortType". 
+ * Types: {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"};
+ * Currently considered compatible ALL types except for objref - they must match exactly
+ */
+bool GraphEditor::OutNode::IsCompatible( const char* OutPortType, const char* InPortType ) const {
+  bool ret = true;
+  string t1 = OutPortType;
+  string t2 = InPortType;
+  // if ANY is an objref - the other one must be objref as well
+  if ( ( t1 == "objref" || t2 == "objref" ) && t1 != t2 ) 
+    ret = false; 
+  return ret;
+}
 
 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
   f << (GraphBase::ComputingNode ) *(G.Graph()) ;