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 //PAL9048 JR Debug : a node may not have the same name as the graph
652 bool GraphNodeSameName = false ;
653 if ( theNodeName && !strcmp( Graph()->Name() , theNodeName ) ) {
654 GraphNodeSameName = true ;
656 if ( NodeKindOfNode == SUPERV::InLineNode ||
657 NodeKindOfNode == SUPERV::LoopNode ||
658 NodeKindOfNode == SUPERV::EndLoopNode ||
659 NodeKindOfNode == SUPERV::SwitchNode ||
660 NodeKindOfNode == SUPERV::EndSwitchNode ||
661 NodeKindOfNode == SUPERV::GOTONode ) {
662 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
663 if ( NodeKindOfNode == SUPERV::InLineNode ) {
664 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
666 else if ( NodeKindOfNode == SUPERV::LoopNode ) {
667 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
669 else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
670 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
672 else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
673 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
675 else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
676 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
678 else if ( NodeKindOfNode == SUPERV::GOTONode ) {
679 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
683 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
685 theNodeName = NULLSTRING ;
687 //PAL9048 JR Debug : a node may not have the same name as the graph
688 // if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) {
689 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ||
690 Graph()->GetGraphNode( theNodeName ) || GraphNodeSameName ) {
691 cdebug << "OutNode::AddNode : '" << theNodeName << "' GraphNodeSameName "
692 << GraphNodeSameName << endl;
693 aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
694 strcpy( aNodeName , NodeService.ServiceName ) ;
695 // if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
696 if ( Graph()->GetGraphNode( NodeService.ServiceName ) || GraphNodeSameName ) {
697 GeneratedName = true ;
698 while ( Graph()->GetGraphNode( aNodeName ) || GraphNodeSameName ) {
699 cdebug << "OutNode::AddNode : '" << aNodeName << "' exists or GraphNodeSameName "
700 << GraphNodeSameName << endl;
702 delete [] aNodeName ;
704 char * aServiceName = (CORBA::String_member ) NodeService.ServiceName ;
705 int num = Graph()->GetNewServiceInstanceNumber( aServiceName ) ;
707 astr << num << ends ;
708 const char * n_instance = astr.str().c_str() ;
709 int lname = strlen( NodeService.ServiceName ) + 1 +
710 strlen( n_instance ) + 1 ;
711 aNodeName = new char[lname] ;
712 strcpy( aNodeName , NodeService.ServiceName ) ;
713 strcat( aNodeName , "_" ) ;
714 strcat( aNodeName , n_instance ) ;
715 GraphNodeSameName = !strcmp( Graph()->Name() , aNodeName ) ;
720 if ( Graph()->GetGraphNode( theNodeName ) == NULL ) {
721 aNodeName = new char[ strlen( theNodeName )+1 ] ;
722 strcpy( aNodeName , theNodeName ) ;
725 aNodeName = NULLSTRING ;
728 if ( aNodeName != NULLSTRING ) {
729 Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() ,
730 aFuncName , aPythonFunction , NodeService ,
731 NodeComponentName , NodeInterfaceName ,
732 aNodeName , NodeKindOfNode ,
733 NodeFirstCreation , NodeLastModification ,
734 NodeEditorRelease , NodeAuthor ,
735 NodeComputer , NodeComment , GeneratedName ,
737 _prof_debug , _fdebug ) ;
739 // asv: 28.09.04 fix for 6621
740 //if ( Nd->IsMacroNode() )
741 // MapGraph( Nd->GraphMacroNode(), aNodeName );
743 if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) {
745 for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
746 GraphBase::InDataStreamPort * aDataStreamPort ;
747 aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
748 //JR 17.02.2005 Memory Leak my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
749 NodeService.ServiceinDataStreamParameter[i].Parametername ,
750 NodeService.ServiceinDataStreamParameter[i].Parametertype ,
751 NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
752 SUPERV::DataStreamParameter ) ;
754 for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
755 GraphBase::OutDataStreamPort * aDataStreamPort ;
756 aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
757 //JR 17.02.2005 Memory Leak my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
758 NodeService.ServiceoutDataStreamParameter[i].Parametername ,
759 NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
760 NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
761 SUPERV::DataStreamParameter ) ;
765 if ( Graph()->AddNode( Nd->ComputingNode() ) ) {
767 RetVal = Nd->Name() ;
770 cdebug << "NodeName already exists." << endl ;
774 cdebug << "ERROR NodeName is NULL or already exists." << endl ;
776 // delete [] aNodeName ;
779 cdebug_out << "GraphEditor::OutNode::AddNode : NULL" << endl;
782 cdebug_out << "GraphEditor::OutNode::AddNode : " << Nd << " " << Nd->Name() << endl;
787 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
788 const char* FromServiceParameterName ,
789 const char* ToNodeName ,
790 const char* ToServiceParameterName ,
794 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
795 ToServiceParameterName ) ;
796 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
797 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
799 if ( anInPort->IsEndSwitch() ) {
800 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
802 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
805 return anInPort->AddCoord( nXY , X , Y ) ;
811 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
812 const char* FromServiceParameterName ,
813 const char* ToNodeName ,
814 const char* ToServiceParameterName ,
818 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
819 ToServiceParameterName ) ;
820 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
821 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
823 if ( anInPort->IsEndSwitch() ) {
824 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
826 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
829 return anInPort->AddCoord( index , X , Y ) ;
835 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
836 const char* FromServiceParameterName ,
837 const char* ToNodeName ,
838 const char* ToServiceParameterName ,
842 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
843 ToServiceParameterName ) ;
844 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
845 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
847 if ( anInPort->IsEndSwitch() ) {
848 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
850 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
853 return anInPort->ChangeCoord( index , X , Y ) ;
859 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
860 const char* FromServiceParameterName ,
861 const char* ToNodeName ,
862 const char* ToServiceParameterName ,
864 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
865 ToServiceParameterName ) ;
866 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
867 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
869 if ( anInPort->IsEndSwitch() ) {
870 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
872 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
875 return anInPort->RemoveCoord( index ) ;
881 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
882 const char* FromServiceParameterName ,
883 const char* ToNodeName ,
884 const char* ToServiceParameterName ) {
885 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
886 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
887 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
889 if ( anInPort->IsEndSwitch() ) {
890 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
892 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
895 return anInPort->GetCoord() ;
901 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
902 const char* FromServiceParameterName ,
903 const char* ToNodeName ,
904 const char* ToServiceParameterName ,
906 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
907 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
908 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
910 if ( anInPort->IsEndSwitch() ) {
911 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
913 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
916 return anInPort->GetCoord( X , Y ) ;
922 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
923 const char* FromServiceParameterName ,
924 const char* ToNodeName ,
925 const char* ToServiceParameterName ,
926 const int index , long &X , long &Y ) {
927 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
928 ToServiceParameterName ) ;
929 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
930 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
932 if ( anInPort->IsEndSwitch() ) {
933 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
935 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
938 return anInPort->GetCoord( index , X , Y ) ;
944 bool GraphEditor::OutNode::UnValid() {
945 bool RetVal = _Valid ;
947 if ( Graph()->GraphMacroLevel() != 0 ) {
948 cdebug << "GraphEditor::OutNode::UnValid() GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
954 //JR Optional parameter kLoopSwitch (default = true) :
955 //In some cases we do not need to check the validity of loops and switchs
956 bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) {
960 cdebug_in << "GraphEditor::OutNode::Valid" << endl;
961 _Executable = false ;
963 if ( !Graph()->CreateService() ) {
964 cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
968 if ( Graph()->GraphMacroLevel() != 0 ) {
969 cdebug << "CoupledNode " << Graph()->CoupledNode() << endl ;
970 cdebug << "GraphEditor " << Graph()->CoupledNode()->GraphEditor() << endl ;
971 cdebug << "Graph " << Graph()->CoupledNode()->GraphEditor()->Graph() << endl ;
972 cdebug << "Name " << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
973 cdebug << "Valid --> UpdateMacroPorts of " << Graph()->CoupledNodeName() << " of "
974 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
975 cdebug << Graph()->CoupledNode() << endl ;
976 Graph()->CoupledNode()->UpdateMacroPorts( Graph() ) ;
977 cdebug << Graph()->CoupledNode()->Name() << " Valid --> UnValid of graph "
978 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name()
979 << " GraphMacroLevel " << Graph()->CoupledNode()->GraphEditor()->Graph()->GraphMacroLevel() << endl ;
980 Graph()->CoupledNode()->GraphEditor()->UnValid() ;
983 int SubStreamGraphsNumber = 0 ;
984 if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
985 cdebug_out << "This DataFlow is not valid." << endl ;
988 if ( Graph()->IsDataStreamNode() ) {
989 StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
992 Graph()->InLineServices() ;
995 if ( !Graph()->ValidLoops() ) {
996 cdebug_out << "This DataFlow have not valid Loops." << endl ;
999 if ( !Graph()->ValidSwitchs() ) {
1000 cdebug_out << "This DataFlow have not valid Switchs." << endl ;
1005 // CreateService() ;
1007 Graph()->ComputingNodes() ;
1009 if ( kLoopSwitch ) {
1013 cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
1017 bool GraphEditor::OutNode::Executable() {
1018 cdebug_in << "GraphEditor::OutNode::Executable" << endl;
1020 // LinkLoopNodes manage input values of LoopNodes and EndLoopNodes
1021 if ( Graph()->LinkLoopNodes( NewLink ) ) {
1027 cdebug << "This DataFlow is not executable." << endl ;
1028 _Executable = false ;
1036 if ( Graph()->DataServerNodes() )
1037 _Executable = true ;
1039 cdebug << "This DataFlow is not executable." << endl ;
1040 _Executable = false ;
1043 if ( _Executable && Graph()->IsDataStreamNode() ) {
1044 StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
1047 // asv : 13.12.04 : introducing check for compatibility of linked ports' types.
1048 if ( !IsLinksCompatible() ) {
1049 _Executable = false;
1052 cdebug_out << "GraphEditor::OutNode::Executable " << _Executable << endl;
1053 return _Executable ;
1056 //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetInData(
1057 const CORBA::Any GraphEditor::OutNode::GetInData(
1058 const char * ToNodeName ,
1059 const char * ToParameterName ) {
1060 // cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
1061 // << " " << ToParameterName << endl ;
1062 //JR 30.03.2005 const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1063 const CORBA::Any retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1064 // cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
1068 //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetOutData(
1069 const CORBA::Any GraphEditor::OutNode::GetOutData(
1070 const char * FromNodeName ,
1071 const char * FromParameterName ) {
1072 // cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
1073 // << " " << FromParameterName << endl ;
1074 //JR 30.03.2005 const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1075 const CORBA::Any retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1076 // cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
1080 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
1081 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
1082 GraphBase::SLink aLink ,
1083 bool wdata ) const {
1084 cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1085 << "(" << aLink.FromServiceParameterName << ") --> "
1086 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ;
1087 QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
1089 if ( strlen( aLink.FromNodeName.c_str() ) ) {
1090 // f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
1091 // << "</fromnode-name>" << endl ;
1092 aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
1095 // f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
1096 aField = Graph.createTextNode( "?" ) ;
1098 link.appendChild( fromnodename ) ;
1099 fromnodename.appendChild( aField ) ;
1101 // f << Tabs << "<fromserviceparameter-name>"
1102 // << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
1104 QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
1105 aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
1106 link.appendChild( fromserviceparametername ) ;
1107 fromserviceparametername.appendChild( aField ) ;
1109 QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
1110 if ( strlen( aLink.ToNodeName.c_str() ) ) {
1111 // f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
1112 // << "</tonode-name>" << endl ;
1113 aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
1116 // f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
1117 aField = Graph.createTextNode( "?" ) ;
1119 link.appendChild( tonodename ) ;
1120 tonodename.appendChild( aField ) ;
1122 // f << Tabs << "<toserviceparameter-name>"
1123 // << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
1125 QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
1126 aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
1127 link.appendChild( toserviceparametername ) ;
1128 toserviceparametername.appendChild( aField ) ;
1131 // f << Tabs << "<data-value>" << endl ;
1132 QDomElement datavalue = Graph.createElement( "data-value" ) ;
1133 link.appendChild( datavalue ) ;
1134 // f << Tabs << " <value-type>" << aLink.aLinkValue.type()->kind()
1135 // << "</value-type>" << endl ;
1136 QDomElement valuetype = Graph.createElement( "value-type" ) ;
1138 aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
1139 aField = Graph.createTextNode( aKind ) ;
1140 datavalue.appendChild( valuetype ) ;
1141 valuetype.appendChild( aField ) ;
1142 switch (aLink.aLinkValue.type()->kind()) {
1143 case CORBA::tk_string: {
1145 aLink.aLinkValue >>= retstr;
1146 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1147 QDomElement value = Graph.createElement( "value" ) ;
1148 //PAL9133 Debug JR : accept void strings
1149 QDomCDATASection aCDATA = Graph.createCDATASection( retstr ) ;
1150 // aField = Graph.createTextNode( retstr ) ;
1151 aField = Graph.createCDATASection( retstr ) ;
1152 datavalue.appendChild( aCDATA ) ;
1153 // datavalue.appendChild( value ) ;
1154 value.appendChild( aField ) ;
1155 // MESSAGE( "ToString( string ) " << retstr );
1158 case CORBA::tk_double: {
1160 aLink.aLinkValue >>= d;
1161 // f << Tabs << " <value>" << d << "</value>" << endl ;
1162 QDomElement value = Graph.createElement( "value" ) ;
1164 aKind = aKind.setNum( d ) ;
1165 aField = Graph.createTextNode( aKind ) ;
1166 datavalue.appendChild( value ) ;
1167 value.appendChild( aField ) ;
1168 // MESSAGE( "ToString( double ) " << d );
1171 case CORBA::tk_long: {
1173 aLink.aLinkValue >>= l;
1174 // f << Tabs << " <value>" << l << "</value>" << endl ;
1175 QDomElement value = Graph.createElement( "value" ) ;
1177 aKind = aKind.setNum( l ) ;
1178 aField = Graph.createTextNode( aKind ) ;
1179 datavalue.appendChild( value ) ;
1180 value.appendChild( aField ) ;
1181 // MESSAGE( "ToString( long ) " << l );
1184 case CORBA::tk_objref: {
1186 CORBA::Object_ptr obj ;
1187 aLink.aLinkValue >>= obj ;
1188 retstr = _Orb->object_to_string(obj );
1189 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1190 QDomElement value = Graph.createElement( "value" ) ;
1191 aField = Graph.createTextNode( retstr ) ;
1192 datavalue.appendChild( value ) ;
1193 value.appendChild( aField ) ;
1194 // MESSAGE( "ToString( object ) " << retstr );
1198 // f << Tabs << " <value>?</value>" << endl ;
1199 QDomElement value = Graph.createElement( "value" ) ;
1200 aField = Graph.createTextNode( "?" ) ;
1201 datavalue.appendChild( value ) ;
1202 value.appendChild( aField ) ;
1203 // MESSAGE( "Unknown CORBA::Any Type" );
1207 // f << Tabs << "</data-value>" << endl ;
1209 // f << Tabs << "<coord-list>" << endl ;
1210 QDomElement coordlist = Graph.createElement( "coord-list" ) ;
1211 link.appendChild( coordlist ) ;
1214 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1215 // f << Tabs << " <coord>" << endl ;
1216 QDomElement coord = Graph.createElement( "coord" ) ;
1217 coordlist.appendChild( coord ) ;
1218 // f << Tabs << " <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
1219 QDomElement x = Graph.createElement( "x" ) ;
1221 ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
1222 aField = Graph.createTextNode( ax ) ;
1223 coord.appendChild( x ) ;
1224 x.appendChild( aField ) ;
1225 // f << Tabs << " <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
1226 QDomElement y = Graph.createElement( "y" ) ;
1228 ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
1229 aField = Graph.createTextNode( ay ) ;
1230 coord.appendChild( y ) ;
1231 y.appendChild( aField ) ;
1232 // f << Tabs << " </coord>" << endl ;
1234 // f << Tabs << "</coord-list>" << endl ;
1235 cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1236 << "(" << aLink.FromServiceParameterName << ") --> "
1237 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")"
1242 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
1243 GraphBase::SLink aLink ,
1244 bool fromparam , bool toparam ,
1245 bool wdata ) const {
1247 // if ( intervar ) {
1248 // f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1250 // << aLink.FromNodeName.c_str() << ".GetOutPort( '"
1251 // << aLink.FromServiceParameterName.c_str()
1252 // << "' )" << endl ;
1254 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1255 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ;
1256 if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) {
1257 f << " = " << aGraphName << ".StreamLink( " ;
1260 f << " = " << aGraphName << ".Link( " ;
1262 // if ( !fromparam ) {
1265 f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ;
1266 // if ( !toparam ) {
1269 f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ;
1272 f << " " << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
1273 // << " = " << aLink.ToNodeName.c_str() << ".Input( '"
1274 // << aLink.ToServiceParameterName.c_str() << "' , " ;
1276 switch (aLink.aLinkValue.type()->kind()) {
1277 case CORBA::tk_string: {
1279 aLink.aLinkValue >>= retstr;
1280 f << "'" << retstr << "'" ;
1283 case CORBA::tk_double: {
1285 aLink.aLinkValue >>= d;
1289 case CORBA::tk_long: {
1291 aLink.aLinkValue >>= l;
1295 case CORBA::tk_objref: {
1297 CORBA::Object_ptr obj ;
1298 aLink.aLinkValue >>= obj ;
1299 retstr = _Orb->object_to_string(obj );
1300 f << "'" << retstr << "'" ;
1305 // MESSAGE( "Unknown CORBA::Any Type" );
1312 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1313 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1314 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
1315 << aLink.aListOfCoords[ i ].theX << " , "
1316 << aLink.aListOfCoords[ i ].theY << " )" << endl ;
1321 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
1322 bool GraphEditor::OutNode::SaveXML( ostream & f , QDomDocument & GraphQDom ,
1323 bool aSuperGraph , QDomElement & supergraph ) {
1324 cdebug_in << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1325 << Graph()->Name() << endl ;
1328 QDomElement dataflow ;
1329 if ( aSuperGraph ) {
1330 QString SuperGraph("SuperGraph") ;
1331 GraphQDom = QDomDocument(SuperGraph) ;
1333 supergraph = GraphQDom.createElement( "supergraph" ) ;
1334 GraphQDom.appendChild( supergraph ) ;
1336 dataflow = GraphQDom.createElement( "dataflow" ) ;
1337 supergraph.appendChild( dataflow ) ;
1340 // QString Dataflow("Dataflow") ;
1341 // GraphQDom = QDomDocument(Dataflow) ;
1343 dataflow = GraphQDom.createElement( "dataflow" ) ;
1344 supergraph.appendChild( dataflow ) ;
1347 QDomElement info = GraphQDom.createElement( "info-list" ) ;
1348 dataflow.appendChild( info ) ;
1350 Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ;
1352 QDomElement nodelist = GraphQDom.createElement( "node-list" ) ;
1353 dataflow.appendChild( nodelist ) ;
1354 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1355 // f << " <node>" << endl ;
1356 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1357 // ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
1359 ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1360 Graph()->GraphNodes( i )->XCoordinate() ,
1361 Graph()->GraphNodes( i )->YCoordinate() ) ;
1363 else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1364 // ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1366 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1367 Graph()->GraphNodes( i )->XCoordinate() ,
1368 Graph()->GraphNodes( i )->YCoordinate() ) ;
1370 else if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1371 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1373 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1374 Graph()->GraphNodes( i )->XCoordinate() ,
1375 Graph()->GraphNodes( i )->YCoordinate() ) ;
1377 else if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1378 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1380 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1381 Graph()->GraphNodes( i )->XCoordinate() ,
1382 Graph()->GraphNodes( i )->YCoordinate() ) ;
1384 else if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1385 // ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1387 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1388 Graph()->GraphNodes( i )->XCoordinate() ,
1389 Graph()->GraphNodes( i )->YCoordinate() ) ;
1391 else if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1392 // ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1394 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1395 Graph()->GraphNodes( i )->XCoordinate() ,
1396 Graph()->GraphNodes( i )->YCoordinate() ) ;
1398 else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) {
1399 // ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1401 ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1402 Graph()->GraphNodes( i )->XCoordinate() ,
1403 Graph()->GraphNodes( i )->YCoordinate() ) ;
1405 else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1406 // ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1408 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1409 Graph()->GraphNodes( i )->XCoordinate() ,
1410 Graph()->GraphNodes( i )->YCoordinate() ) ;
1412 else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) {
1413 // ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1415 ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1416 Graph()->GraphNodes( i )->XCoordinate() ,
1417 Graph()->GraphNodes( i )->YCoordinate() ) ;
1419 // f << " </node>" << endl ;
1422 // f << " </node-list>" << endl << endl ;
1424 // f << " <link-list>" << endl ;
1425 QDomElement linklist = GraphQDom.createElement( "link-list" ) ;
1426 dataflow.appendChild( linklist ) ;
1427 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1428 for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1429 // f << " <link>" << endl ;
1430 QDomElement link = GraphQDom.createElement( "link" ) ;
1431 linklist.appendChild( link ) ;
1432 // LinkSaveXML( f , " " , (*Links)[ i ] , false ) ;
1433 LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ;
1434 // f << " </link>" << endl ;
1436 // f << " </link-list>" << endl << endl ;
1438 // f << " <data-list>" << endl ;
1439 QDomElement datalist = GraphQDom.createElement( "data-list" ) ;
1440 dataflow.appendChild( datalist ) ;
1441 if ( Graph()->GraphMacroLevel() == 0 ) {
1442 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1443 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1444 // f << " <data>" << endl ;
1445 QDomElement data = GraphQDom.createElement( "data" ) ;
1446 datalist.appendChild( data ) ;
1447 // LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ;
1448 LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ;
1449 // f << " </data>" << endl ;
1453 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1454 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1455 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1456 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1457 cdebug << "OutNode::SaveXML ---> OutNode::SaveXML( ostream & f , QDomDocument & , false "
1458 << " , QDomElement & ) MacroGraph " << aMacroGraph->Name() << endl ;
1459 if ( !aMacroGraph->GraphEditor()->SaveXML( f , GraphQDom , false , supergraph ) ) {
1461 cdebug << "OutNode::SaveXML MacroGraph "<< aMacroGraph->Name() << " done" << endl ;
1466 cdebug_out << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1467 << Graph()->Name() << endl ;
1472 bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
1475 const GraphBase::ListOfSLinks * Links ;
1476 if ( importSuperV ) {
1477 f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
1479 f << "from SuperV import *" << endl << endl ;
1482 f << "# Graph creation of " << Graph()->Name() << endl ;
1483 f << "def Def" << Graph()->Name() << "() :" << endl ;
1484 Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ;
1486 f << " " << endl << " " << "# Creation of Factory Nodes" << endl ;
1487 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1488 if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1490 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1491 Graph()->GraphNodes( i )->XCoordinate() ,
1492 Graph()->GraphNodes( i )->YCoordinate() ) ;
1497 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1498 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1500 f << " " << endl << " " << "# Creation of Computing Nodes" << endl ;
1506 ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1507 Graph()->GraphNodes( i )->XCoordinate() ,
1508 Graph()->GraphNodes( i )->YCoordinate() ) ;
1513 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1514 if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1516 f << " " << endl << " " << "# Creation of InLine Nodes" << endl ;
1522 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1523 Graph()->GraphNodes( i )->XCoordinate() ,
1524 Graph()->GraphNodes( i )->YCoordinate() ) ;
1529 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1530 if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1532 f << " " << endl << " " << "# Creation of Loop Nodes" << endl ;
1538 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1539 Graph()->GraphNodes( i )->XCoordinate() ,
1540 Graph()->GraphNodes( i )->YCoordinate() ) ;
1545 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1546 if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1548 f << " " << endl << " " << "# Creation of Switch Nodes" << endl ;
1554 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1555 Graph()->GraphNodes( i )->XCoordinate() ,
1556 Graph()->GraphNodes( i )->YCoordinate() ) ;
1561 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1562 if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1564 f << " " << endl << " " << "# Creation of GOTO Nodes" << endl ;
1570 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1571 Graph()->GraphNodes( i )->XCoordinate() ,
1572 Graph()->GraphNodes( i )->YCoordinate() ) ;
1577 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1578 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1580 f << " " << endl << " " << "# Creation of Macro Nodes" << endl ;
1586 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1587 Graph()->GraphNodes( i )->XCoordinate() ,
1588 Graph()->GraphNodes( i )->YCoordinate() ) ;
1592 Links = Graph()->GetLinks() ;
1594 // map< string , int > aMapOfOutPorts ;
1596 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1597 for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1598 if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1601 << " " << "# Creation of Links"
1608 // char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1609 // strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1610 // strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1611 // strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1612 // if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1613 // aMapOfOutPorts[ NodePort ] = j + 1 ;
1614 // intervar = true ;
1617 // intervar = false ;
1619 bool fromparam = false ;
1620 if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) {
1623 bool toparam = false ;
1624 if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) {
1627 LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ;
1628 // delete [] NodePort ;
1633 if ( Graph()->GraphMacroLevel() == 0 ) {
1634 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1636 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1638 f << " " << endl << " " << "# Input datas" << endl ;
1641 bool fromparam = true ;
1642 bool toparam = true ;
1643 LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ;
1648 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ;
1649 for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1650 string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1651 const char * aParam = _aParam.c_str() ;
1655 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1656 // if ( aParam[ j ] == '\\' ) {
1657 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1658 aNodeName = new char[ j+1 ] ;
1659 strncpy( aNodeName , aParam , j ) ;
1660 aNodeName[ j ] = '\0' ;
1661 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1662 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1666 const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ;
1667 if ( !anInPort->IsDataConnected() ) {
1669 f << " " << endl << " " << "# Input Ports of the graph" << endl ;
1672 f << " " << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '"
1673 << aPortName << "' )" << endl ;
1675 delete [] aNodeName ;
1676 delete [] aPortName ;
1679 f << " " << endl << " # Output Ports of the graph" << endl ;
1680 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ;
1681 for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1682 string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1683 const char * aParam = _aParam.c_str() ;
1687 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1688 // if ( aParam[ j ] == '\\' ) {
1689 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1690 aNodeName = new char[ j+1 ] ;
1691 strncpy( aNodeName , aParam , j ) ;
1692 aNodeName[ j ] = '\0' ;
1693 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1694 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1698 f << " " << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '"
1699 << aPortName << "' )" << endl ;
1700 delete [] aNodeName ;
1701 delete [] aPortName ;
1704 f << " " << "return " << Graph()->Name() << endl << endl ;
1706 // RECURSIVE CREATION OF GRAPHS OF MACRONODES
1707 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1708 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1709 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1710 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1711 cdebug << "OutNode::SavePY ---> OutNode::SavePY( ostream & f ) MacroGraph " << aMacroGraph->Name() << endl ;
1712 GraphEditor::DataFlow * aDataFlow = aMacroGraph->GraphEditor() ;
1713 cdebug << "SavePY of the Graph " << aDataFlow->Graph() << " of the MacroNode "
1714 << aMacroGraph->Name() << endl ;
1715 if ( !aDataFlow->SavePY( f , false ) ) {
1721 // f << Graph()->Name() << " = " << Graph()->Name() << "()" << endl ;
1726 /** Iterate through ALL links (OutPort-InPort pairs) and check if their types are
1727 * compatible - call GraphEditor::DataFlow::IsCompatible(type1, type2).
1728 * Returns true if all are compatible.
1730 bool GraphEditor::OutNode::IsLinksCompatible() {
1731 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1733 for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) {
1734 GraphBase::SLink aLink = (*Links)[i];
1735 GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() );
1736 GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() );
1737 const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() );
1738 const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() );
1739 b = IsCompatible( anOutPort->PortType(), anInPort->PortType() );
1740 cdebug << "GraphEditor::OutNode::IsLinksCompatible: "<<aLink.FromNodeName << "("<<aLink.FromServiceParameterName
1741 <<") --> "<<aLink.ToNodeName<<"("<<aLink.ToServiceParameterName<<") = " << (b ? "OK" : "Not compatible (ERROR)") << endl;
1743 MESSAGE( "Graph structure ERROR: type of port \""<<aLink.FromServiceParameterName<<"\" of node \""
1744 <<aLink.FromNodeName<<"\" is not compatible with type of linked port \""
1745 <<aLink.ToServiceParameterName<<"\" of node \""<<aLink.ToNodeName<<"\"" );
1750 static const char* gSimpleTypes[] =
1751 {"boolean", "char", "short", "int", "long", "float", "double"};
1752 bool isSimpleType( string type ) {
1753 for ( int i = 0; i < 7; i++ )
1754 if ( type == gSimpleTypes[i] )
1759 /**Returns true if an out-port of type "OutPortType" can be bound with in-port of type "InPortType".
1760 * Types: {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"};
1761 * Currently considered compatible ALL types except for objref - they must match exactly
1763 bool GraphEditor::OutNode::IsCompatible( const char* OutPortType, const char* InPortType ) const {
1765 string t1 = OutPortType;
1766 string t2 = InPortType;
1767 // if ANY is a string - the link is OK
1768 if ( t1 == "string" || t2 == "string" )
1771 // the next check prohibits linkage of "objref" to any simple type (int, char, etc.)
1772 // it is still possible to link "objref" to some UNKNOWN type (probably objref, too,
1773 // which interface name came from Cataloge
1774 else if ( ( t1 == "objref" && isSimpleType( t2 ) ) ||
1775 ( t2 == "objref" && isSimpleType( t1 ) ) )
1780 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1781 f << (GraphBase::ComputingNode ) *(G.Graph()) ;
1784 f << " Nodes : " << (G.Graph())->GraphNodesSize() << " node"
1785 << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl;
1788 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1790 // << hex << (void *) G.Graph().GraphNodes( i ) << dec << " "
1791 << (G.Graph())->GraphNodes( i ) << endl;
1794 f << " Links : " << endl ;
1795 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1796 (G.Graph())->GraphNodes( i )->ListLinks( f ) ;
1799 f << " Datas : " << endl ;
1800 (G.Graph())->ListDatas( f ) ;
1802 f << "DataFlow " << (G.Graph())->Name() << " is " ;
1803 if ( G.IsNotValid() )
1805 f << "valid and is " ;
1806 if ( G.IsNotExecutable() )
1808 f << "executable." << endl ;
1815 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1817 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1819 fOut << D.Day << "/"
1826 // cdebug_out << "operator<< GraphEditor::Date" << endl;
1831 GraphBase::Graph * GraphEditor::OutNode::MapGraph( const char * aGraphName ) {
1832 GraphBase::Graph * aGraph = _MapOfGraphs[ aGraphName ] ;
1836 bool GraphEditor::OutNode::MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) {
1837 if ( MapGraph( aGraphName ) ) {
1840 _MapOfGraphs[ aGraphName ] = aGraph ;
1844 void GraphEditor::OutNode::EraseGraph( const char * aGraphName ) {
1845 _MapOfGraphs.erase( aGraphName ) ;
1848 bool GraphEditor::OutNode::GraphName( const char * aGraphName ) {
1849 return _MapOfGraphNames[ aGraphName ] ;