1 // SUPERV GraphEditor : contains classes that permit edition of graphs
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowEditor_OutNode.cxx
30 #include "DataFlowEditor_DataFlow.hxx"
31 #include "DataFlowEditor_OutNode.hxx"
32 #include "DataFlowBase_EndOfLoopNode.hxx"
33 #include "DataFlowBase_EndOfSwitchNode.hxx"
35 //map< string , GraphBase::Graph * > GraphEditor::OutNode::_MapOfGraphs;
36 map< string , int > _MapOfGraphNames;
38 string GraphInstanceName( const char * aGraphName ) {
39 int GraphInstanceNumber = _MapOfGraphNames[ aGraphName ] ;
40 if ( GraphInstanceNumber ) {
41 _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
44 GraphInstanceNumber = 0 ;
45 _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
47 string theGraphInstanceName = string( aGraphName ) ;
48 if ( GraphInstanceNumber ) {
49 theGraphInstanceName += "_" ;
51 astr << GraphInstanceNumber ;
52 theGraphInstanceName += astr.str() ;
54 return theGraphInstanceName ;
58 // Implementation de la classe GraphEditor::Graph
60 GraphEditor::OutNode::OutNode() {
62 cdebug_in << "GraphEditor::OutNode::OutNode()" << endl;
69 cdebug_out << "GraphEditor::OutNode::OutNode()" << endl;
72 GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB ,
73 SALOME_NamingService * ptrNamingService ,
74 const char * DataFlowName ,
75 const char * DebugFileName ,
76 const SUPERV::KindOfNode aKindOfNode ) {
77 // Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
79 Set_prof_debug( ORB , DebugFileName ) ;
80 cdebug_in << "GraphEditor::OutNode::OutNode(" ;
82 cdebug << DataFlowName ;
84 cdebug << ")" << endl;
86 if ( aKindOfNode == SUPERV::DataFlowGraph ) {
88 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
89 _prof_debug , _fdebug ) ;
90 // MapGraph( _Graph , _Graph->Name() ) ;
92 else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
93 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
94 _prof_debug , _fdebug ) ;
95 _Graph = _StreamGraph ;
96 // MapGraph( _Graph , _Graph->Name() ) ;
98 _Orb = CORBA::ORB::_duplicate( ORB ) ;
101 _Executable = false ;
103 cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
106 GraphEditor::OutNode::OutNode(
108 SALOME_NamingService * ptrNamingService ,
109 const SALOME_ModuleCatalog::Service& DataFlowService ,
110 const char * DataFlowComponentName ,
111 const char * DataFlowInterfaceName ,
112 const char * DataFlowName ,
113 const SUPERV::KindOfNode DataFlowkind ,
114 const SUPERV::SDate DataFlowFirstCreation ,
115 const SUPERV::SDate DataFlowLastModification ,
116 const char * DataFlowEditorRelease ,
117 const char * DataFlowAuthor ,
118 const char * DataFlowComputer ,
119 const char * DataFlowComment ,
120 const char * DebugFileName ) {
122 Set_prof_debug( ORB , DebugFileName ) ;
124 if ( DataFlowkind == SUPERV::DataFlowGraph ) {
125 _StreamGraph = NULL ;
126 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
127 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
128 DataFlowFirstCreation , DataFlowLastModification ,
129 DataFlowEditorRelease , DataFlowAuthor ,
130 DataFlowComputer , DataFlowComment ,
131 _prof_debug , _fdebug ) ;
132 // MapGraph( _Graph , _Graph->Name() ) ;
134 else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
135 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
136 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
137 DataFlowFirstCreation , DataFlowLastModification ,
138 DataFlowEditorRelease , DataFlowAuthor ,
139 DataFlowComputer , DataFlowComment ,
140 _prof_debug , _fdebug ) ;
141 _Graph = _StreamGraph ;
142 // MapGraph( _Graph , _Graph->Name() ) ;
144 _Orb = CORBA::ORB::_duplicate( ORB ) ;
147 _Executable = false ;
151 GraphEditor::OutNode::~OutNode() {
152 // EraseGraph( Graph->Name() ) ;
153 // delete _DataFlowNode ;
154 // delete _DataFlowDatas ;
158 bool GraphEditor::OutNode::Name( const char * aName ) {
159 bool RetVal = false ;
160 // if ( !GraphName( aName ) ) {
161 // char * aGraphName = Graph()->Name() ;
162 RetVal = Graph()->Name( aName ) ;
164 // EraseGraph( aGraphName ) ;
165 // MapGraph( Graph() , aName ) ;
171 void GraphEditor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
172 const char * DebugFileName ) {
173 _Graph_prof_debug = 0 ;
175 if ( DebugFileName ) {
176 _fdebug = new ofstream( DebugFileName );
177 SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
178 MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
182 bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
183 bool RetVal = false ;
184 cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << (*aDataFlow).Info.theName.c_str()
185 << " GraphNodesSize " << Graph()->GraphNodesSize() << endl;
187 RetVal = LoadInfo( (*aDataFlow).Info ) ;
190 else if ( Graph()->IsDataStreamNode() || (*aDataFlow).Info.theKind == SUPERV::DataFlowGraph ) {
193 cdebug << "GraphEditor::OutNode::LoadDataFlow() _Imported " << _Imported << " RetVal " << RetVal << endl;
195 map< string , int > aMapOfNodes ;
197 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadNodes GraphNodesSize " << Graph()->GraphNodesSize() << endl;
198 RetVal = LoadNodes( aMapOfNodes , (*aDataFlow).Nodes ) ;
201 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadLinks GraphNodesSize " << Graph()->GraphNodesSize() << endl;
202 RetVal = LoadLinks( aMapOfNodes , (*aDataFlow).Links ) ;
206 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl;
207 RetVal = LoadDatas( aMapOfNodes , (*aDataFlow).Datas ) ;
209 cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize()
210 << " RetVal " << RetVal << endl;
214 bool GraphEditor::OutNode::LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) {
215 bool RetVal = false ;
216 // GraphBase::ListOfSGraphs aListOfDataFlows ;
217 if ( myFileName == NULL ) {
218 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
220 char * aDataFlowName = Graph()->Name() ;
221 // Name( Graph()->Name() ) ;
222 Name( GraphInstanceName( Graph()->Name() ).c_str() ) ;
223 // MapGraph( Graph() , Graph()->Name() ) ;
224 cdebug << "GraphEditor::OutNode::LoadXml() " << aDataFlowName << " --> " << Graph()->Name() << endl;
228 cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
229 RetVal = Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ;
230 // RetVal = LoadDataFlows( &aListOfDataFlows ) ;
231 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << " " << aListOfDataFlows.size()
232 << " Graphs" << endl;
238 bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
239 bool RetVal = false ;
240 GraphBase::ListOfSGraphs aListOfDataFlows ;
241 if ( myFileName == NULL ) {
242 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
246 else if ( Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ) {
247 cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
248 RetVal = LoadDataFlows( &aListOfDataFlows ) ;
249 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl;
255 bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
256 bool RetVal = false ;
257 cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
259 // MESSAGE( "GraphEditor::OutNode::LoadInfo" );
260 // ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
261 // InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
262 if ( Graph()->IsDataStreamNode() || aDataFlowInfo.theKind == SUPERV::DataFlowGraph ) {
263 char * aDataFlowName = Graph()->Name() ;
264 // Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
265 Graph()->Name( GraphInstanceName( aDataFlowInfo.theName.c_str() ).c_str() ) ;
266 // MapGraph( Graph() , Graph()->Name() ) ;
267 cdebug << "GraphEditor::OutNode::LoadInfo " << aDataFlowName << " --> " << Graph()->Name()
268 << " aDataFlowInfo.Kind " << aDataFlowInfo.theKind << " Kind() " << Graph()->Kind() << endl ;
269 if ( Graph()->IsDataStreamNode() ) {
270 Graph()->Kind( SUPERV::DataStreamGraph ) ;
271 StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
274 Graph()->Kind( SUPERV::DataFlowGraph ) ;
276 Graph()->SetService( aDataFlowInfo.theService ) ;
277 Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
278 Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
279 Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
280 Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ;
281 // Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
282 Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
283 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
284 // Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
288 Graph()->Kind( aDataFlowInfo.theKind ) ;
289 cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
290 << " != IsDataStreamNode() " << Graph()->IsDataStreamNode() << endl ;
292 cdebug_out << "GraphEditor::OutNode::LoadInfo " << RetVal << endl ;
296 bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
297 const GraphBase::ListOfSNodes &aListOfNodes ) {
298 GraphEditor::InNode * anInNode ;
299 cdebug_in << "GraphEditor::OutNode::LoadNodes " << endl ;
301 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
302 GraphBase::SNode aNode = aListOfNodes[ i ] ;
303 const char * aNodeName = aNode.theName.c_str() ;
304 // cout << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
305 // << aNode.theService.ServiceinParameter.length() << " InParameters "
306 // << aNode.theService.ServiceoutParameter.length() << " OutParameters "
307 // << aNode.theListOfInDataStreams.size() << " InDataStreams "
308 // << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
309 // << " _prof_debug " << _prof_debug << endl ;
310 cdebug << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
311 << aNode.theService.ServiceinParameter.length() << " InParameters "
312 << aNode.theService.ServiceoutParameter.length() << " OutParameters "
313 << aNode.theListOfInDataStreams.size() << " InDataStreams "
314 << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
316 if ( aNode.theListOfFuncName.size() == 0 ) {
317 aNode.theListOfFuncName.resize( 1 ) ;
318 aNode.theListOfFuncName[ 0 ] = "" ;
319 aNode.theListOfPythonFunctions.resize( 1 ) ;
320 aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
322 if ( Graph()->GetGraphNode( aNode.theName.c_str() ) ) {
323 aNodeName = NULLSTRING ;
326 aNode.theService.ServiceinDataStreamParameter.length( aNode.theListOfInDataStreams.size() ) ;
327 aNode.theService.ServiceoutDataStreamParameter.length( aNode.theListOfOutDataStreams.size() ) ;
329 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
330 aNode.theService.ServiceinDataStreamParameter[ j ].Parametername = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
331 aNode.theService.ServiceinDataStreamParameter[ j ].Parametertype = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
332 aNode.theService.ServiceinDataStreamParameter[ j ].Parameterdependency = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
334 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
335 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametername = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
336 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametertype = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
337 aNode.theService.ServiceoutDataStreamParameter[ j ].Parameterdependency = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
340 anInNode = AddNode( aNode.theService ,
341 aNode.theListOfFuncName ,
342 aNode.theListOfPythonFunctions ,
343 aNode.theComponentName.c_str() ,
344 aNode.theInterfaceName.c_str() , aNodeName ,
346 aNode.theFirstCreation , aNode.theLastModification ,
347 aNode.theEditorRelease.c_str() ,
348 aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
349 aNode.theComment.c_str() ,
350 aNode.theCoords.theX , aNode.theCoords.theY ) ;
351 string * aNodetheName = new string( aNode.theName ) ;
352 aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ;
353 if ( anInNode->IsOneOfInLineNodes() || anInNode->IsMacroNode() ) {
354 anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
355 _Orb , aNode.theService , anInNode->NamePtr() ,
357 _prof_debug , _fdebug ) ;
358 GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
359 GraphBase::LoopNode * aLNode = NULL ;
360 if ( aINode->IsLoopNode() ) {
361 aLNode = anInNode->LoopNode() ;
362 aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
363 *aNode.theListOfPythonFunctions[ 0 ] ) ;
364 aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
365 *aNode.theListOfPythonFunctions[ 1 ] ) ;
366 aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
367 *aNode.theListOfPythonFunctions[ 2 ] ) ;
369 else if ( aINode->IsMacroNode() || aINode->IsInLineNode() || aINode->IsGOTONode() ||
370 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
371 aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
372 *aNode.theListOfPythonFunctions[ 0 ] ) ;
376 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
377 GraphBase::InPort * anInPort ;
378 if ( anInNode->IsOneOfInLineNodes() ) {
379 anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
380 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
381 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
382 SUPERV::DataStreamParameter ) ;
385 anInPort = anInNode->ComputingNode()->GetChangeInPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ) ;
387 ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
388 aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
389 aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
391 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
392 GraphBase::OutPort * anOutPort ;
393 if ( anInNode->IsOneOfInLineNodes() ) {
394 anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
395 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
396 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
397 SUPERV::DataStreamParameter ) ;
400 anOutPort = anInNode->ComputingNode()->GetChangeOutPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ) ;
402 ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
404 delete aNodetheName ;
410 // setting coupled pairs of nodes: Loop-EndLoop, Switch-EndSwitch, InLine-GOTO, MacroNode-Graph
411 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
412 GraphBase::SNode aNode = aListOfNodes[ i ] ;
413 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
414 << aNode.theCoupledNode.c_str() << endl ;
415 anInNode = (GraphEditor::InNode * ) Graph()->GetChangeGraphNode( aMapOfNodes[ aNode.theName.c_str() ] )->GetInNode() ;
417 if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
418 GraphBase::GOTONode * aGOTONode;
419 aGOTONode = (GraphBase::GOTONode * ) anInNode->ComputingNode() ;
421 // asv : 25.10.04 : if aNode is a MacroNode, then its coupled node (another Graph) is NOT in aMapOfNodes
422 // and we must couple MacroNode only with name to its subgraph
423 if ( aGOTONode->IsMacroNode() ) {
424 cdebug << "GraphEditor::OutNode::LoadNodes MacroNode " << aNode.theName.c_str()
425 << " is Coupled ONLY WITH NAME to its subgraph " << aNode.theCoupledNode.c_str() << endl;
426 aGOTONode->CoupledNodeName( aNode.theCoupledNode.c_str() ) ;
428 else { // coupling Loop-EndLoop, Switch-EndSwitch, InLine-GOTO
429 // asv : fix for 6822 : using map because if aNode's name is the same as some existing node's name
430 // aMap will give the correct index any way (aMap has already a different name for aNode, SNode still has old name)
431 int aCoupledNodeIndex = aMapOfNodes[ aNode.theCoupledNode.c_str() ] ;
432 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theCoupledNode.c_str()
433 << " index " << aCoupledNodeIndex << endl ;
434 GraphBase::GOTONode * aCoupledNode ;
435 aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aCoupledNodeIndex ) ;
436 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str()
437 << " is now Coupled to " << aNode.theCoupledNode.c_str() << endl ;
438 aGOTONode->CoupledNode( aCoupledNode ) ;
442 cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
446 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
447 const GraphBase::ListOfSLinks &aListOfLinks ) {
450 cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
451 // MESSAGE( "GraphEditor::OutNode::LoadLinks" );
453 for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
454 GraphBase::SLink aLink = aListOfLinks[ i ] ;
455 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
456 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
457 cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( "
458 << aLink.FromServiceParameterName.c_str() << " ) --> "
459 << aLinkToNodeName->c_str() << "( "
460 << aLink.ToServiceParameterName.c_str() << " )" << endl ;
461 if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
462 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
463 //JR 08.02.2005 : Rule of CEA : a bad graph may be stored in a xml
464 RetAddLink = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
465 aLink.FromServiceParameterName.c_str() ,
466 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
467 aLink.ToServiceParameterName.c_str() ) ;
472 if ( RetVal && RetAddLink ) {
473 for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
474 RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
475 aLink.FromServiceParameterName.c_str() ,
476 Graph()->GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
477 aLink.ToServiceParameterName.c_str() ,
479 aLink.aListOfCoords[j].theX ,
480 aLink.aListOfCoords[j].theY ) ;
485 delete aLinkFromNodeName ;
486 delete aLinkToNodeName ;
488 cdebug_out << "GraphEditor::OutNode::LoadLinks " << RetVal << endl ;
492 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
493 const GraphBase::ListOfSLinks &aListOfDatas ) {
496 cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
497 // MESSAGE( "GraphEditor::OutNode::LoadDatas" );
499 for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
500 GraphBase::SLink aLink = aListOfDatas[ i ] ;
501 cdebug << "OutNode::LoadDatas " << i << aLink.FromNodeName.c_str() << "(" << aLink.FromServiceParameterName
502 << ") --> " << aLink.ToNodeName.c_str() << "(" << aLink.ToServiceParameterName << ") CORBA::tk_xxx "
503 << aLink.aLinkValue.type()->kind() << endl ;
504 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
505 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
506 // cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
507 // << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
508 // cout << " " << aLink.ToNodeName.c_str() << " "
509 // << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
510 RetAddLink = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
511 aLink.ToServiceParameterName.c_str() ,
513 delete aLinkFromNodeName ;
514 delete aLinkToNodeName ;
518 cdebug_out << "GraphEditor::OutNode::LoadDatas " << RetVal << endl ;
522 bool GraphEditor::OutNode::SaveXml(const char* filename) {
524 cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
525 ofstream f(filename);
527 QDomDocument DomGraph ;
528 QDomElement Domsupergraph ;
529 cdebug << "OutNode::SaveXML("<< filename << ") ---> OutNode::SaveXML( ostream & f , QDomDocument & , true "
530 << " , QDomElement & ) " << Graph()->Name() << endl ;
531 test = SaveXML( f , DomGraph , true , Domsupergraph );
532 QString xml = DomGraph.toString() ;
535 cdebug << "OutNode::SaveXML("<< filename << ") done" << endl ;
537 // QString xml = Graph.toString() ;
538 // cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
539 // f << xml << endl ;
541 cdebug_out << "GraphEditor::OutNode::SaveXml " << test << endl;
546 bool GraphEditor::OutNode::SavePy( const char* filename ) {
548 cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
549 ofstream f( filename ) ;
551 test = SavePY( f , true );
552 f << endl << Graph()->Name() << " = Def" << Graph()->Name() << "()" << endl ;
553 cdebug_out << "GraphEditor::OutNode::SavePy " << test << endl;
557 GraphBase::ListOfSGraphs * GraphEditor::OutNode::GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
558 // GraphBase::ListOfSGraphs * aListOfDataFlows = new GraphBase::ListOfSGraphs;
559 int index = aListOfDataFlows->size() ;
560 aListOfDataFlows->resize( index + 1 ) ;
561 if ( Graph()->IsDataFlowNode() ) {
562 (*aListOfDataFlows)[ index ].Info = *Graph()->GetInfo() ;
563 (*aListOfDataFlows)[ index ].Nodes = *Graph()->GetNodes() ;
564 (*aListOfDataFlows)[ index ].Links = *Graph()->GetLinks( true ) ;
565 (*aListOfDataFlows)[ index ].Datas = *Graph()->GetDatas() ;
568 (*aListOfDataFlows)[ index ].Info = *StreamGraph()->GetInfo() ;
569 (*aListOfDataFlows)[ index ].Nodes = *StreamGraph()->GetNodes() ;
570 (*aListOfDataFlows)[ index ].Links = *StreamGraph()->GetLinks( true ) ;
571 (*aListOfDataFlows)[ index ].Datas = *StreamGraph()->GetDatas() ;
574 for ( i = 0 ; i < (int ) (*aListOfDataFlows)[ index ].Nodes.size() ; i++ ) {
575 const GraphBase::ComputingNode * aNode = Graph()->GetGraphNode( (*aListOfDataFlows)[ index ].Nodes[i].theName.c_str() ) ;
576 if ( aNode->IsMacroNode() ) {
577 // string aCoupledNodeName = (*aListOfDataFlows)[ index ].Nodes[i].theCoupledNode ;
578 GraphBase::Graph * aGraph = (GraphBase::Graph * ) ((GraphBase::GOTONode * ) aNode )->CoupledNode() ;
579 // GraphBase::Graph * aGraph = MapGraph( aCoupledNodeName.c_str() ) ;
580 aGraph->GraphEditor()->GraphEditor::OutNode::GetDataFlows( aListOfDataFlows ) ;
583 return aListOfDataFlows ;
586 void GraphEditor::OutNode::DateModification() {
587 time_t T = time(NULL);
588 struct tm * Tm = localtime(&T);
589 SUPERV::SDate aLastModificationDate ;
591 aLastModificationDate.Second = Tm->tm_sec;
592 aLastModificationDate.Minute = Tm->tm_min;
593 aLastModificationDate.Hour = Tm->tm_hour;
594 aLastModificationDate.Day = Tm->tm_mday;
595 aLastModificationDate.Month = Tm->tm_mon + 1;
596 aLastModificationDate.Year = Tm->tm_year + 1900;
597 Graph()->LastModification( aLastModificationDate ) ;
600 void GraphEditor::OutNode::Coordinates( const char* NodeName ,
603 ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
606 const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
607 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->XCoordinate() ;
610 const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
611 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->YCoordinate() ;
614 GraphEditor::InNode * GraphEditor::OutNode::AddNode(
615 const SALOME_ModuleCatalog::Service& NodeService ,
616 GraphBase::ListOfFuncName aFuncName ,
617 GraphBase::ListOfPythonFunctions aPythonFunction ,
618 const char * NodeComponentName ,
619 const char * NodeInterfaceName ,
620 const char * theNodeName ,
621 const SUPERV::KindOfNode NodeKindOfNode ,
622 const SUPERV::SDate NodeFirstCreation ,
623 const SUPERV::SDate NodeLastModification ,
624 const char * NodeEditorRelease ,
625 const char * NodeAuthor ,
626 const char * NodeComputer ,
627 const char * NodeComment ,
630 cdebug_in << "GraphEditor::OutNode::AddNode( " ;
631 if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) {
632 cdebug << "Component('" << NodeComponentName << "') , Node('" ;
635 cdebug << "NodeComponentName[NULL] )" << endl;
637 if ( theNodeName == NULL ) {
638 theNodeName = NULLSTRING ;
640 if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) {
641 cdebug << theNodeName << "' )" ;
644 cdebug << "NodeName[NULLSTRING]' )" ;
646 cdebug << " " << NodeKindOfNode << endl ;
647 char * RetVal = NULLSTRING ;
648 GraphEditor::InNode *Nd = NULL ;
649 char * aNodeName = NULLSTRING ;
650 bool GeneratedName = false ;
651 if ( NodeKindOfNode == SUPERV::InLineNode ||
652 NodeKindOfNode == SUPERV::LoopNode ||
653 NodeKindOfNode == SUPERV::EndLoopNode ||
654 NodeKindOfNode == SUPERV::SwitchNode ||
655 NodeKindOfNode == SUPERV::EndSwitchNode ||
656 NodeKindOfNode == SUPERV::GOTONode ) {
657 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
658 if ( NodeKindOfNode == SUPERV::InLineNode ) {
659 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
661 else if ( NodeKindOfNode == SUPERV::LoopNode ) {
662 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
664 else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
665 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
667 else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
668 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
670 else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
671 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
673 else if ( NodeKindOfNode == SUPERV::GOTONode ) {
674 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
678 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
680 theNodeName = NULLSTRING ;
682 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) {
683 aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
684 strcpy( aNodeName , NodeService.ServiceName ) ;
685 if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
686 GeneratedName = true ;
687 while ( Graph()->GetGraphNode( aNodeName ) ) {
689 delete [] aNodeName ;
691 int num = Graph()->GetServiceNameNumber( NodeService ) ;
693 astr << num << ends ;
694 const char * n_instance = astr.str().c_str() ;
695 int lname = strlen( NodeService.ServiceName ) + 1 +
696 strlen( n_instance ) + 1 ;
697 aNodeName = new char[lname] ;
698 strcpy( aNodeName , NodeService.ServiceName ) ;
699 strcat( aNodeName , "_" ) ;
700 strcat( aNodeName , n_instance ) ;
705 if ( Graph()->GetGraphNode( theNodeName ) == NULL ) {
706 aNodeName = new char[ strlen( theNodeName )+1 ] ;
707 strcpy( aNodeName , theNodeName ) ;
710 aNodeName = NULLSTRING ;
713 if ( aNodeName != NULLSTRING ) {
714 Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() ,
715 aFuncName , aPythonFunction , NodeService ,
716 NodeComponentName , NodeInterfaceName ,
717 aNodeName , NodeKindOfNode ,
718 NodeFirstCreation , NodeLastModification ,
719 NodeEditorRelease , NodeAuthor ,
720 NodeComputer , NodeComment , GeneratedName ,
722 _prof_debug , _fdebug ) ;
724 // asv: 28.09.04 fix for 6621
725 //if ( Nd->IsMacroNode() )
726 // MapGraph( Nd->GraphMacroNode(), aNodeName );
728 if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) {
730 for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
731 GraphBase::InDataStreamPort * aDataStreamPort ;
732 aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
733 //JR 17.02.2005 Memory Leak my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
734 NodeService.ServiceinDataStreamParameter[i].Parametername ,
735 NodeService.ServiceinDataStreamParameter[i].Parametertype ,
736 NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
737 SUPERV::DataStreamParameter ) ;
739 for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
740 GraphBase::OutDataStreamPort * aDataStreamPort ;
741 aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
742 //JR 17.02.2005 Memory Leak my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
743 NodeService.ServiceoutDataStreamParameter[i].Parametername ,
744 NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
745 NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
746 SUPERV::DataStreamParameter ) ;
750 if ( Graph()->AddNode( Nd->ComputingNode() ) ) {
752 RetVal = Nd->Name() ;
755 cdebug << "NodeName already exists." << endl ;
759 cdebug << "ERROR NodeName is NULL or already exists." << endl ;
761 // delete [] aNodeName ;
762 cdebug_out << "GraphEditor::OutNode::AddNode" << endl;
767 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
768 const char* FromServiceParameterName ,
769 const char* ToNodeName ,
770 const char* ToServiceParameterName ,
774 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
775 ToServiceParameterName ) ;
776 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
777 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
779 if ( anInPort->IsEndSwitch() ) {
780 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
782 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
785 return anInPort->AddCoord( nXY , X , Y ) ;
791 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
792 const char* FromServiceParameterName ,
793 const char* ToNodeName ,
794 const char* ToServiceParameterName ,
798 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
799 ToServiceParameterName ) ;
800 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
801 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
803 if ( anInPort->IsEndSwitch() ) {
804 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
806 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
809 return anInPort->AddCoord( index , X , Y ) ;
815 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
816 const char* FromServiceParameterName ,
817 const char* ToNodeName ,
818 const char* ToServiceParameterName ,
822 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
823 ToServiceParameterName ) ;
824 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
825 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
827 if ( anInPort->IsEndSwitch() ) {
828 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
830 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
833 return anInPort->ChangeCoord( index , X , Y ) ;
839 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
840 const char* FromServiceParameterName ,
841 const char* ToNodeName ,
842 const char* ToServiceParameterName ,
844 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
845 ToServiceParameterName ) ;
846 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
847 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
849 if ( anInPort->IsEndSwitch() ) {
850 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
852 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
855 return anInPort->RemoveCoord( index ) ;
861 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
862 const char* FromServiceParameterName ,
863 const char* ToNodeName ,
864 const char* ToServiceParameterName ) {
865 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
866 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
867 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
869 if ( anInPort->IsEndSwitch() ) {
870 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
872 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
875 return anInPort->GetCoord() ;
881 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
882 const char* FromServiceParameterName ,
883 const char* ToNodeName ,
884 const char* ToServiceParameterName ,
886 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
887 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
888 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
890 if ( anInPort->IsEndSwitch() ) {
891 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
893 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
896 return anInPort->GetCoord( X , Y ) ;
902 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
903 const char* FromServiceParameterName ,
904 const char* ToNodeName ,
905 const char* ToServiceParameterName ,
906 const int index , long &X , long &Y ) {
907 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
908 ToServiceParameterName ) ;
909 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
910 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
912 if ( anInPort->IsEndSwitch() ) {
913 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
915 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
918 return anInPort->GetCoord( index , X , Y ) ;
924 bool GraphEditor::OutNode::UnValid() {
925 bool RetVal = _Valid ;
927 if ( Graph()->GraphMacroLevel() != 0 ) {
928 cdebug << "GraphEditor::OutNode::UnValid() GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
934 //JR Optional parameter kLoopSwitch (default = true) :
935 //In some cases we do not need to check the validity of loops and switchs
936 bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) {
940 cdebug_in << "GraphEditor::OutNode::Valid" << endl;
941 _Executable = false ;
943 if ( !Graph()->CreateService() ) {
944 cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
948 if ( Graph()->GraphMacroLevel() != 0 ) {
949 cdebug << "CoupledNode " << Graph()->CoupledNode() << endl ;
950 cdebug << "GraphEditor " << Graph()->CoupledNode()->GraphEditor() << endl ;
951 cdebug << "Graph " << Graph()->CoupledNode()->GraphEditor()->Graph() << endl ;
952 cdebug << "Name " << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
953 cdebug << "Valid --> UpdateMacroPorts of " << Graph()->CoupledNodeName() << " of "
954 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
955 cdebug << Graph()->CoupledNode() << endl ;
956 Graph()->CoupledNode()->UpdateMacroPorts( Graph() ) ;
957 cdebug << Graph()->CoupledNode()->Name() << " Valid --> UnValid of graph "
958 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name()
959 << " GraphMacroLevel " << Graph()->CoupledNode()->GraphEditor()->Graph()->GraphMacroLevel() << endl ;
960 Graph()->CoupledNode()->GraphEditor()->UnValid() ;
963 int SubStreamGraphsNumber = 0 ;
964 if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
965 cdebug_out << "This DataFlow is not valid." << endl ;
968 if ( Graph()->IsDataStreamNode() ) {
969 StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
972 Graph()->InLineServices() ;
975 if ( !Graph()->ValidLoops() ) {
976 cdebug_out << "This DataFlow have not valid Loops." << endl ;
979 if ( !Graph()->ValidSwitchs() ) {
980 cdebug_out << "This DataFlow have not valid Switchs." << endl ;
987 Graph()->ComputingNodes() ;
993 cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
997 bool GraphEditor::OutNode::Executable() {
998 cdebug_in << "GraphEditor::OutNode::Executable" << endl;
1000 // LinkLoopNodes manage input values of LoopNodes and EndLoopNodes
1001 if ( Graph()->LinkLoopNodes( NewLink ) ) {
1007 cdebug << "This DataFlow is not executable." << endl ;
1008 _Executable = false ;
1016 if ( Graph()->DataServerNodes() )
1017 _Executable = true ;
1019 cdebug << "This DataFlow is not executable." << endl ;
1020 _Executable = false ;
1023 if ( _Executable && Graph()->IsDataStreamNode() ) {
1024 StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
1027 // asv : 13.12.04 : introducing check for compatibility of linked ports' types.
1028 if ( !IsLinksCompatible() ) {
1029 _Executable = false;
1032 cdebug_out << "GraphEditor::OutNode::Executable" << endl;
1033 return _Executable ;
1036 const CORBA::Any *GraphEditor::OutNode::GetInData(
1037 const char * ToNodeName ,
1038 const char * ToParameterName ) {
1039 // cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
1040 // << " " << ToParameterName << endl ;
1041 const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1042 // cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
1046 const CORBA::Any *GraphEditor::OutNode::GetOutData(
1047 const char * FromNodeName ,
1048 const char * FromParameterName ) {
1049 // cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
1050 // << " " << FromParameterName << endl ;
1051 const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1052 // cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
1056 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
1057 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
1058 GraphBase::SLink aLink ,
1059 bool wdata ) const {
1060 cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1061 << "(" << aLink.FromServiceParameterName << ") --> "
1062 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ;
1063 QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
1065 if ( strlen( aLink.FromNodeName.c_str() ) ) {
1066 // f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
1067 // << "</fromnode-name>" << endl ;
1068 aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
1071 // f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
1072 aField = Graph.createTextNode( "?" ) ;
1074 link.appendChild( fromnodename ) ;
1075 fromnodename.appendChild( aField ) ;
1077 // f << Tabs << "<fromserviceparameter-name>"
1078 // << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
1080 QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
1081 aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
1082 link.appendChild( fromserviceparametername ) ;
1083 fromserviceparametername.appendChild( aField ) ;
1085 QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
1086 if ( strlen( aLink.ToNodeName.c_str() ) ) {
1087 // f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
1088 // << "</tonode-name>" << endl ;
1089 aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
1092 // f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
1093 aField = Graph.createTextNode( "?" ) ;
1095 link.appendChild( tonodename ) ;
1096 tonodename.appendChild( aField ) ;
1098 // f << Tabs << "<toserviceparameter-name>"
1099 // << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
1101 QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
1102 aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
1103 link.appendChild( toserviceparametername ) ;
1104 toserviceparametername.appendChild( aField ) ;
1107 // f << Tabs << "<data-value>" << endl ;
1108 QDomElement datavalue = Graph.createElement( "data-value" ) ;
1109 link.appendChild( datavalue ) ;
1110 // f << Tabs << " <value-type>" << aLink.aLinkValue.type()->kind()
1111 // << "</value-type>" << endl ;
1112 QDomElement valuetype = Graph.createElement( "value-type" ) ;
1114 aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
1115 aField = Graph.createTextNode( aKind ) ;
1116 datavalue.appendChild( valuetype ) ;
1117 valuetype.appendChild( aField ) ;
1118 switch (aLink.aLinkValue.type()->kind()) {
1119 case CORBA::tk_string: {
1121 aLink.aLinkValue >>= retstr;
1122 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1123 QDomElement value = Graph.createElement( "value" ) ;
1124 aField = Graph.createTextNode( retstr ) ;
1125 datavalue.appendChild( value ) ;
1126 value.appendChild( aField ) ;
1127 // MESSAGE( "ToString( string ) " << retstr );
1130 case CORBA::tk_double: {
1132 aLink.aLinkValue >>= d;
1133 // f << Tabs << " <value>" << d << "</value>" << endl ;
1134 QDomElement value = Graph.createElement( "value" ) ;
1136 aKind = aKind.setNum( d ) ;
1137 aField = Graph.createTextNode( aKind ) ;
1138 datavalue.appendChild( value ) ;
1139 value.appendChild( aField ) ;
1140 // MESSAGE( "ToString( double ) " << d );
1143 case CORBA::tk_long: {
1145 aLink.aLinkValue >>= l;
1146 // f << Tabs << " <value>" << l << "</value>" << endl ;
1147 QDomElement value = Graph.createElement( "value" ) ;
1149 aKind = aKind.setNum( l ) ;
1150 aField = Graph.createTextNode( aKind ) ;
1151 datavalue.appendChild( value ) ;
1152 value.appendChild( aField ) ;
1153 // MESSAGE( "ToString( long ) " << l );
1156 case CORBA::tk_objref: {
1158 CORBA::Object_ptr obj ;
1159 aLink.aLinkValue >>= obj ;
1160 retstr = _Orb->object_to_string(obj );
1161 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1162 QDomElement value = Graph.createElement( "value" ) ;
1163 aField = Graph.createTextNode( retstr ) ;
1164 datavalue.appendChild( value ) ;
1165 value.appendChild( aField ) ;
1166 // MESSAGE( "ToString( object ) " << retstr );
1170 // f << Tabs << " <value>?</value>" << endl ;
1171 QDomElement value = Graph.createElement( "value" ) ;
1172 aField = Graph.createTextNode( "?" ) ;
1173 datavalue.appendChild( value ) ;
1174 value.appendChild( aField ) ;
1175 // MESSAGE( "Unknown CORBA::Any Type" );
1179 // f << Tabs << "</data-value>" << endl ;
1181 // f << Tabs << "<coord-list>" << endl ;
1182 QDomElement coordlist = Graph.createElement( "coord-list" ) ;
1183 link.appendChild( coordlist ) ;
1186 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1187 // f << Tabs << " <coord>" << endl ;
1188 QDomElement coord = Graph.createElement( "coord" ) ;
1189 coordlist.appendChild( coord ) ;
1190 // f << Tabs << " <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
1191 QDomElement x = Graph.createElement( "x" ) ;
1193 ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
1194 aField = Graph.createTextNode( ax ) ;
1195 coord.appendChild( x ) ;
1196 x.appendChild( aField ) ;
1197 // f << Tabs << " <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
1198 QDomElement y = Graph.createElement( "y" ) ;
1200 ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
1201 aField = Graph.createTextNode( ay ) ;
1202 coord.appendChild( y ) ;
1203 y.appendChild( aField ) ;
1204 // f << Tabs << " </coord>" << endl ;
1206 // f << Tabs << "</coord-list>" << endl ;
1207 cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1208 << "(" << aLink.FromServiceParameterName << ") --> "
1209 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")"
1214 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
1215 GraphBase::SLink aLink ,
1216 bool fromparam , bool toparam ,
1217 bool wdata ) const {
1219 // if ( intervar ) {
1220 // f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1222 // << aLink.FromNodeName.c_str() << ".GetOutPort( '"
1223 // << aLink.FromServiceParameterName.c_str()
1224 // << "' )" << endl ;
1226 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1227 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ;
1228 if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) {
1229 f << " = " << aGraphName << ".StreamLink( " ;
1232 f << " = " << aGraphName << ".Link( " ;
1234 // if ( !fromparam ) {
1237 f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ;
1238 // if ( !toparam ) {
1241 f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ;
1244 f << " " << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
1245 // << " = " << aLink.ToNodeName.c_str() << ".Input( '"
1246 // << aLink.ToServiceParameterName.c_str() << "' , " ;
1248 switch (aLink.aLinkValue.type()->kind()) {
1249 case CORBA::tk_string: {
1251 aLink.aLinkValue >>= retstr;
1252 f << "'" << retstr << "'" ;
1255 case CORBA::tk_double: {
1257 aLink.aLinkValue >>= d;
1261 case CORBA::tk_long: {
1263 aLink.aLinkValue >>= l;
1267 case CORBA::tk_objref: {
1269 CORBA::Object_ptr obj ;
1270 aLink.aLinkValue >>= obj ;
1271 retstr = _Orb->object_to_string(obj );
1272 f << "'" << retstr << "'" ;
1277 // MESSAGE( "Unknown CORBA::Any Type" );
1284 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1285 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1286 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
1287 << aLink.aListOfCoords[ i ].theX << " , "
1288 << aLink.aListOfCoords[ i ].theY << " )" << endl ;
1293 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
1294 bool GraphEditor::OutNode::SaveXML( ostream & f , QDomDocument & GraphQDom ,
1295 bool aSuperGraph , QDomElement & supergraph ) {
1296 cdebug_in << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1297 << Graph()->Name() << endl ;
1300 QDomElement dataflow ;
1301 if ( aSuperGraph ) {
1302 QString SuperGraph("SuperGraph") ;
1303 GraphQDom = QDomDocument(SuperGraph) ;
1305 supergraph = GraphQDom.createElement( "supergraph" ) ;
1306 GraphQDom.appendChild( supergraph ) ;
1308 dataflow = GraphQDom.createElement( "dataflow" ) ;
1309 supergraph.appendChild( dataflow ) ;
1312 // QString Dataflow("Dataflow") ;
1313 // GraphQDom = QDomDocument(Dataflow) ;
1315 dataflow = GraphQDom.createElement( "dataflow" ) ;
1316 supergraph.appendChild( dataflow ) ;
1319 QDomElement info = GraphQDom.createElement( "info-list" ) ;
1320 dataflow.appendChild( info ) ;
1322 Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ;
1324 QDomElement nodelist = GraphQDom.createElement( "node-list" ) ;
1325 dataflow.appendChild( nodelist ) ;
1326 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1327 // f << " <node>" << endl ;
1328 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1329 // ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
1331 ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1332 Graph()->GraphNodes( i )->XCoordinate() ,
1333 Graph()->GraphNodes( i )->YCoordinate() ) ;
1335 else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1336 // ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1338 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1339 Graph()->GraphNodes( i )->XCoordinate() ,
1340 Graph()->GraphNodes( i )->YCoordinate() ) ;
1342 else if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1343 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1345 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1346 Graph()->GraphNodes( i )->XCoordinate() ,
1347 Graph()->GraphNodes( i )->YCoordinate() ) ;
1349 else if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1350 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1352 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1353 Graph()->GraphNodes( i )->XCoordinate() ,
1354 Graph()->GraphNodes( i )->YCoordinate() ) ;
1356 else if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1357 // ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1359 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1360 Graph()->GraphNodes( i )->XCoordinate() ,
1361 Graph()->GraphNodes( i )->YCoordinate() ) ;
1363 else if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1364 // ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1366 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1367 Graph()->GraphNodes( i )->XCoordinate() ,
1368 Graph()->GraphNodes( i )->YCoordinate() ) ;
1370 else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) {
1371 // ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1373 ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1374 Graph()->GraphNodes( i )->XCoordinate() ,
1375 Graph()->GraphNodes( i )->YCoordinate() ) ;
1377 else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1378 // ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1380 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1381 Graph()->GraphNodes( i )->XCoordinate() ,
1382 Graph()->GraphNodes( i )->YCoordinate() ) ;
1384 else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) {
1385 // ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1387 ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1388 Graph()->GraphNodes( i )->XCoordinate() ,
1389 Graph()->GraphNodes( i )->YCoordinate() ) ;
1391 // f << " </node>" << endl ;
1394 // f << " </node-list>" << endl << endl ;
1396 // f << " <link-list>" << endl ;
1397 QDomElement linklist = GraphQDom.createElement( "link-list" ) ;
1398 dataflow.appendChild( linklist ) ;
1399 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1400 for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1401 // f << " <link>" << endl ;
1402 QDomElement link = GraphQDom.createElement( "link" ) ;
1403 linklist.appendChild( link ) ;
1404 // LinkSaveXML( f , " " , (*Links)[ i ] , false ) ;
1405 LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ;
1406 // f << " </link>" << endl ;
1408 // f << " </link-list>" << endl << endl ;
1410 // f << " <data-list>" << endl ;
1411 QDomElement datalist = GraphQDom.createElement( "data-list" ) ;
1412 dataflow.appendChild( datalist ) ;
1413 if ( Graph()->GraphMacroLevel() == 0 ) {
1414 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1415 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1416 // f << " <data>" << endl ;
1417 QDomElement data = GraphQDom.createElement( "data" ) ;
1418 datalist.appendChild( data ) ;
1419 // LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ;
1420 LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ;
1421 // f << " </data>" << endl ;
1425 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1426 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1427 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1428 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1429 cdebug << "OutNode::SaveXML ---> OutNode::SaveXML( ostream & f , QDomDocument & , false "
1430 << " , QDomElement & ) MacroGraph " << aMacroGraph->Name() << endl ;
1431 if ( !aMacroGraph->GraphEditor()->SaveXML( f , GraphQDom , false , supergraph ) ) {
1433 cdebug << "OutNode::SaveXML MacroGraph "<< aMacroGraph->Name() << " done" << endl ;
1438 cdebug_out << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1439 << Graph()->Name() << endl ;
1444 bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
1447 const GraphBase::ListOfSLinks * Links ;
1448 if ( importSuperV ) {
1449 f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
1451 f << "from SuperV import *" << endl << endl ;
1454 f << "# Graph creation of " << Graph()->Name() << endl ;
1455 f << "def Def" << Graph()->Name() << "() :" << endl ;
1456 Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ;
1458 f << " " << endl << " " << "# Creation of Factory Nodes" << endl ;
1459 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1460 if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1462 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1463 Graph()->GraphNodes( i )->XCoordinate() ,
1464 Graph()->GraphNodes( i )->YCoordinate() ) ;
1469 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1470 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1472 f << " " << endl << " " << "# Creation of Computing Nodes" << endl ;
1478 ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1479 Graph()->GraphNodes( i )->XCoordinate() ,
1480 Graph()->GraphNodes( i )->YCoordinate() ) ;
1485 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1486 if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1488 f << " " << endl << " " << "# Creation of InLine Nodes" << endl ;
1494 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1495 Graph()->GraphNodes( i )->XCoordinate() ,
1496 Graph()->GraphNodes( i )->YCoordinate() ) ;
1501 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1502 if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1504 f << " " << endl << " " << "# Creation of Loop Nodes" << endl ;
1510 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1511 Graph()->GraphNodes( i )->XCoordinate() ,
1512 Graph()->GraphNodes( i )->YCoordinate() ) ;
1517 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1518 if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1520 f << " " << endl << " " << "# Creation of Switch Nodes" << endl ;
1526 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1527 Graph()->GraphNodes( i )->XCoordinate() ,
1528 Graph()->GraphNodes( i )->YCoordinate() ) ;
1533 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1534 if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1536 f << " " << endl << " " << "# Creation of GOTO Nodes" << endl ;
1542 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1543 Graph()->GraphNodes( i )->XCoordinate() ,
1544 Graph()->GraphNodes( i )->YCoordinate() ) ;
1549 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1550 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1552 f << " " << endl << " " << "# Creation of Macro Nodes" << endl ;
1558 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1559 Graph()->GraphNodes( i )->XCoordinate() ,
1560 Graph()->GraphNodes( i )->YCoordinate() ) ;
1564 Links = Graph()->GetLinks() ;
1566 // map< string , int > aMapOfOutPorts ;
1568 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1569 for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1570 if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1573 << " " << "# Creation of Links"
1580 // char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1581 // strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1582 // strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1583 // strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1584 // if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1585 // aMapOfOutPorts[ NodePort ] = j + 1 ;
1586 // intervar = true ;
1589 // intervar = false ;
1591 bool fromparam = false ;
1592 if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) {
1595 bool toparam = false ;
1596 if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) {
1599 LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ;
1600 // delete [] NodePort ;
1605 if ( Graph()->GraphMacroLevel() == 0 ) {
1606 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1608 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1610 f << " " << endl << " " << "# Input datas" << endl ;
1613 bool fromparam = true ;
1614 bool toparam = true ;
1615 LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ;
1620 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ;
1621 for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1622 string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1623 const char * aParam = _aParam.c_str() ;
1627 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1628 // if ( aParam[ j ] == '\\' ) {
1629 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1630 aNodeName = new char[ j+1 ] ;
1631 strncpy( aNodeName , aParam , j ) ;
1632 aNodeName[ j ] = '\0' ;
1633 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1634 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1638 const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ;
1639 if ( !anInPort->IsDataConnected() ) {
1641 f << " " << endl << " " << "# Input Ports of the graph" << endl ;
1644 f << " " << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '"
1645 << aPortName << "' )" << endl ;
1647 delete [] aNodeName ;
1648 delete [] aPortName ;
1651 f << " " << endl << " # Output Ports of the graph" << endl ;
1652 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ;
1653 for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1654 string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1655 const char * aParam = _aParam.c_str() ;
1659 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1660 // if ( aParam[ j ] == '\\' ) {
1661 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1662 aNodeName = new char[ j+1 ] ;
1663 strncpy( aNodeName , aParam , j ) ;
1664 aNodeName[ j ] = '\0' ;
1665 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1666 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1670 f << " " << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '"
1671 << aPortName << "' )" << endl ;
1672 delete [] aNodeName ;
1673 delete [] aPortName ;
1676 f << " " << "return " << Graph()->Name() << endl << endl ;
1678 // RECURSIVE CREATION OF GRAPHS OF MACRONODES
1679 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1680 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1681 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1682 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1683 cdebug << "OutNode::SavePY ---> OutNode::SavePY( ostream & f ) MacroGraph " << aMacroGraph->Name() << endl ;
1684 GraphEditor::DataFlow * aDataFlow = aMacroGraph->GraphEditor() ;
1685 cdebug << "SavePY of the Graph " << aDataFlow->Graph() << " of the MacroNode "
1686 << aMacroGraph->Name() << endl ;
1687 if ( !aDataFlow->SavePY( f , false ) ) {
1693 // f << Graph()->Name() << " = " << Graph()->Name() << "()" << endl ;
1698 /** Iterate through ALL links (OutPort-InPort pairs) and check if their types are
1699 * compatible - call GraphEditor::DataFlow::IsCompatible(type1, type2).
1700 * Returns true if all are compatible.
1702 bool GraphEditor::OutNode::IsLinksCompatible() {
1703 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1705 for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) {
1706 GraphBase::SLink aLink = (*Links)[i];
1707 GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() );
1708 GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() );
1709 const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() );
1710 const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() );
1711 b = IsCompatible( anOutPort->PortType(), anInPort->PortType() );
1712 cdebug << "GraphEditor::OutNode::IsLinksCompatible: "<<aLink.FromNodeName << "("<<aLink.FromServiceParameterName
1713 <<") --> "<<aLink.ToNodeName<<"("<<aLink.ToServiceParameterName<<") = " << (b ? "OK" : "Not compatible (ERROR)") << endl;
1715 MESSAGE( "Graph structure ERROR: type of port \""<<aLink.FromServiceParameterName<<"\" of node \""
1716 <<aLink.FromNodeName<<"\" is not compatible with type of linked port \""
1717 <<aLink.ToServiceParameterName<<"\" of node \""<<aLink.ToNodeName<<"\"" );
1722 static const char* gSimpleTypes[] =
1723 {"boolean", "char", "short", "int", "long", "float", "double"};
1724 bool isSimpleType( string type ) {
1725 for ( int i = 0; i < 7; i++ )
1726 if ( type == gSimpleTypes[i] )
1731 /**Returns true if an out-port of type "OutPortType" can be bound with in-port of type "InPortType".
1732 * Types: {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"};
1733 * Currently considered compatible ALL types except for objref - they must match exactly
1735 bool GraphEditor::OutNode::IsCompatible( const char* OutPortType, const char* InPortType ) const {
1737 string t1 = OutPortType;
1738 string t2 = InPortType;
1739 // if ANY is a string - the link is OK
1740 if ( t1 == "string" || t2 == "string" )
1743 // the next check prohibits linkage of "objref" to any simple type (int, char, etc.)
1744 // it is still possible to link "objref" to some UNKNOWN type (probably objref, too,
1745 // which interface name came from Cataloge
1746 else if ( ( t1 == "objref" && isSimpleType( t2 ) ) ||
1747 ( t2 == "objref" && isSimpleType( t1 ) ) )
1752 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1753 f << (GraphBase::ComputingNode ) *(G.Graph()) ;
1756 f << " Nodes : " << (G.Graph())->GraphNodesSize() << " node"
1757 << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl;
1760 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1762 // << hex << (void *) G.Graph().GraphNodes( i ) << dec << " "
1763 << (G.Graph())->GraphNodes( i ) << endl;
1766 f << " Links : " << endl ;
1767 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1768 (G.Graph())->GraphNodes( i )->ListLinks( f ) ;
1771 f << " Datas : " << endl ;
1772 (G.Graph())->ListDatas( f ) ;
1774 f << "DataFlow " << (G.Graph())->Name() << " is " ;
1775 if ( G.IsNotValid() )
1777 f << "valid and is " ;
1778 if ( G.IsNotExecutable() )
1780 f << "executable." << endl ;
1787 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1789 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1791 fOut << D.Day << "/"
1798 // cdebug_out << "operator<< GraphEditor::Date" << endl;
1803 GraphBase::Graph * GraphEditor::OutNode::MapGraph( const char * aGraphName ) {
1804 GraphBase::Graph * aGraph = _MapOfGraphs[ aGraphName ] ;
1808 bool GraphEditor::OutNode::MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) {
1809 if ( MapGraph( aGraphName ) ) {
1812 _MapOfGraphs[ aGraphName ] = aGraph ;
1816 void GraphEditor::OutNode::EraseGraph( const char * aGraphName ) {
1817 _MapOfGraphs.erase( aGraphName ) ;
1820 bool GraphEditor::OutNode::GraphName( const char * aGraphName ) {
1821 return _MapOfGraphNames[ aGraphName ] ;