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 ) {
40 // For Macro nodes : names of subgraphs must be unique and differ from the main dataflow
41 // name (i.e. the dataflow with MacroLevel = 0).
42 // It is neccessary for reqursive call of LoadDataFlows(...) method for MacroNodes execution.
43 int GraphInstanceNumber = _MapOfGraphNames[ aGraphName ] ;
44 string theGraphInstanceName = string( aGraphName ) ;
45 if ( GraphInstanceNumber ) {
46 theGraphInstanceName += "_" ;
48 astr << GraphInstanceNumber ;
49 theGraphInstanceName += astr.str() ;
51 if ( theGraphInstanceName != string( aGraphName ) )
52 _MapOfGraphNames[ theGraphInstanceName ] = GraphInstanceNumber ;
53 _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
55 return theGraphInstanceName ;
59 // Implementation de la classe GraphEditor::Graph
61 GraphEditor::OutNode::OutNode() {
63 cdebug_in << "GraphEditor::OutNode::OutNode()" << endl;
70 cdebug_out << "GraphEditor::OutNode::OutNode()" << endl;
73 GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB ,
74 SALOME_NamingService * ptrNamingService ,
75 const char * DataFlowName ,
76 const char * DebugFileName ,
77 const SUPERV::KindOfNode aKindOfNode ) {
78 // Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
80 Set_prof_debug( ORB , DebugFileName ) ;
81 cdebug_in << "GraphEditor::OutNode::OutNode(" ;
83 cdebug << DataFlowName ;
85 cdebug << ")" << endl;
87 if ( aKindOfNode == SUPERV::DataFlowGraph ) {
89 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
90 _prof_debug , _fdebug ) ;
91 // MapGraph( _Graph , _Graph->Name() ) ;
93 else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
94 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
95 _prof_debug , _fdebug ) ;
96 _Graph = _StreamGraph ;
97 // MapGraph( _Graph , _Graph->Name() ) ;
99 _Orb = CORBA::ORB::_duplicate( ORB ) ;
102 _Executable = false ;
104 cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
107 GraphEditor::OutNode::OutNode(
109 SALOME_NamingService * ptrNamingService ,
110 const SALOME_ModuleCatalog::Service& DataFlowService ,
111 const char * DataFlowComponentName ,
112 const char * DataFlowInterfaceName ,
113 const char * DataFlowName ,
114 const SUPERV::KindOfNode DataFlowkind ,
115 const SUPERV::SDate DataFlowFirstCreation ,
116 const SUPERV::SDate DataFlowLastModification ,
117 const char * DataFlowEditorRelease ,
118 const char * DataFlowAuthor ,
119 const char * DataFlowComputer ,
120 const char * DataFlowComment ,
121 const char * DebugFileName ) {
123 Set_prof_debug( ORB , DebugFileName ) ;
125 if ( DataFlowkind == SUPERV::DataFlowGraph ) {
126 _StreamGraph = NULL ;
127 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
128 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
129 DataFlowFirstCreation , DataFlowLastModification ,
130 DataFlowEditorRelease , DataFlowAuthor ,
131 DataFlowComputer , DataFlowComment ,
132 _prof_debug , _fdebug ) ;
133 // MapGraph( _Graph , _Graph->Name() ) ;
135 else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
136 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
137 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
138 DataFlowFirstCreation , DataFlowLastModification ,
139 DataFlowEditorRelease , DataFlowAuthor ,
140 DataFlowComputer , DataFlowComment ,
141 _prof_debug , _fdebug ) ;
142 _Graph = _StreamGraph ;
143 // MapGraph( _Graph , _Graph->Name() ) ;
145 _Orb = CORBA::ORB::_duplicate( ORB ) ;
148 _Executable = false ;
152 GraphEditor::OutNode::~OutNode() {
153 // EraseGraph( Graph->Name() ) ;
154 // delete _DataFlowNode ;
155 // delete _DataFlowDatas ;
159 bool GraphEditor::OutNode::Name( const char * aName ) {
160 bool RetVal = false ;
161 // if ( !GraphName( aName ) ) {
162 // char * aGraphName = Graph()->Name() ;
163 RetVal = Graph()->Name( aName ) ;
165 // EraseGraph( aGraphName ) ;
166 // MapGraph( Graph() , aName ) ;
172 void GraphEditor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
173 const char * DebugFileName ) {
174 _Graph_prof_debug = 0 ;
176 if ( DebugFileName ) {
177 _fdebug = new ofstream( DebugFileName );
178 SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
179 MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
183 bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
184 bool RetVal = false ;
185 cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << (*aDataFlow).Info.theName.c_str()
186 << " GraphNodesSize " << Graph()->GraphNodesSize() << endl;
188 RetVal = LoadInfo( (*aDataFlow).Info ) ;
191 else if ( Graph()->IsDataStreamNode() || (*aDataFlow).Info.theKind == SUPERV::DataFlowGraph ) {
194 cdebug << "GraphEditor::OutNode::LoadDataFlow() _Imported " << _Imported << " RetVal " << RetVal << endl;
196 map< string , int > aMapOfNodes ;
198 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadNodes GraphNodesSize " << Graph()->GraphNodesSize() << endl;
199 RetVal = LoadNodes( aMapOfNodes , (*aDataFlow).Nodes ) ;
202 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadLinks GraphNodesSize " << Graph()->GraphNodesSize() << endl;
203 RetVal = LoadLinks( aMapOfNodes , (*aDataFlow).Links ) ;
207 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl;
208 RetVal = LoadDatas( aMapOfNodes , (*aDataFlow).Datas ) ;
210 cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize()
211 << " _Valid " << _Valid << " _Executable " << _Executable << " RetVal " << RetVal << endl;
215 bool GraphEditor::OutNode::LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) {
216 bool RetVal = false ;
217 // GraphBase::ListOfSGraphs aListOfDataFlows ;
218 if ( myFileName == NULL ) {
219 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
221 char * aDataFlowName = Graph()->Name() ;
222 // Name( Graph()->Name() ) ;
223 Name( GraphInstanceName( Graph()->Name() ).c_str() ) ;
224 // MapGraph( Graph() , Graph()->Name() ) ;
225 cdebug << "GraphEditor::OutNode::LoadXml() " << aDataFlowName << " --> " << Graph()->Name() << endl;
229 cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
230 RetVal = Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ;
231 // RetVal = LoadDataFlows( &aListOfDataFlows ) ;
232 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << " " << aListOfDataFlows.size()
233 << " Graphs" << endl;
239 bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
240 bool RetVal = false ;
241 GraphBase::ListOfSGraphs aListOfDataFlows ;
242 if ( myFileName == NULL ) {
243 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
247 else if ( Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ) {
248 cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
249 RetVal = LoadDataFlows( &aListOfDataFlows ) ;
250 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl;
256 bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
257 bool RetVal = false ;
258 cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
260 // MESSAGE( "GraphEditor::OutNode::LoadInfo" );
261 // ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
262 // InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
263 if ( Graph()->IsDataStreamNode() || aDataFlowInfo.theKind == SUPERV::DataFlowGraph ) {
264 char * aDataFlowName = Graph()->Name() ;
265 // Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
266 Graph()->Name( GraphInstanceName( aDataFlowInfo.theName.c_str() ).c_str() ) ;
267 // MapGraph( Graph() , Graph()->Name() ) ;
268 cdebug << "GraphEditor::OutNode::LoadInfo " << aDataFlowName << " --> " << Graph()->Name()
269 << " aDataFlowInfo.Kind " << aDataFlowInfo.theKind << " Kind() " << Graph()->Kind() << endl ;
270 if ( Graph()->IsDataStreamNode() ) {
271 Graph()->Kind( SUPERV::DataStreamGraph ) ;
272 StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
275 Graph()->Kind( SUPERV::DataFlowGraph ) ;
277 Graph()->SetService( aDataFlowInfo.theService ) ;
278 Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
279 Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
280 Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
281 Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ;
282 // Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
283 Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
284 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
285 // Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
289 Graph()->Kind( aDataFlowInfo.theKind ) ;
290 cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
291 << " != IsDataStreamNode() " << Graph()->IsDataStreamNode() << endl ;
293 cdebug_out << "GraphEditor::OutNode::LoadInfo " << RetVal << endl ;
297 bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
298 const GraphBase::ListOfSNodes &aListOfNodes ) {
299 GraphEditor::InNode * anInNode ;
300 cdebug_in << "GraphEditor::OutNode::LoadNodes " << endl ;
302 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
303 GraphBase::SNode aNode = aListOfNodes[ i ] ;
304 const char * aNodeName = aNode.theName.c_str() ;
305 // cout << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
306 // << aNode.theService.ServiceinParameter.length() << " InParameters "
307 // << aNode.theService.ServiceoutParameter.length() << " OutParameters "
308 // << aNode.theListOfInDataStreams.size() << " InDataStreams "
309 // << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
310 // << " _prof_debug " << _prof_debug << endl ;
311 cdebug << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
312 << aNode.theService.ServiceinParameter.length() << " InParameters "
313 << aNode.theService.ServiceoutParameter.length() << " OutParameters "
314 << aNode.theListOfInDataStreams.size() << " InDataStreams "
315 << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
317 if ( aNode.theListOfFuncName.size() == 0 ) {
318 aNode.theListOfFuncName.resize( 1 ) ;
319 aNode.theListOfFuncName[ 0 ] = "" ;
320 aNode.theListOfPythonFunctions.resize( 1 ) ;
321 aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
323 if ( Graph()->GetGraphNode( aNode.theName.c_str() ) ) {
324 aNodeName = NULLSTRING ;
327 aNode.theService.ServiceinDataStreamParameter.length( aNode.theListOfInDataStreams.size() ) ;
328 aNode.theService.ServiceoutDataStreamParameter.length( aNode.theListOfOutDataStreams.size() ) ;
330 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
331 aNode.theService.ServiceinDataStreamParameter[ j ].Parametername = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
332 aNode.theService.ServiceinDataStreamParameter[ j ].Parametertype = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
333 aNode.theService.ServiceinDataStreamParameter[ j ].Parameterdependency = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
335 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
336 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametername = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
337 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametertype = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
338 aNode.theService.ServiceoutDataStreamParameter[ j ].Parameterdependency = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
341 anInNode = AddNode( aNode.theService ,
342 aNode.theListOfFuncName ,
343 aNode.theListOfPythonFunctions ,
344 aNode.theComponentName.c_str() ,
345 aNode.theInterfaceName.c_str() , aNodeName ,
347 aNode.theFirstCreation , aNode.theLastModification ,
348 aNode.theEditorRelease.c_str() ,
349 aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
350 aNode.theComment.c_str() ,
351 aNode.theCoords.theX , aNode.theCoords.theY ) ;
352 string * aNodetheName = new string( aNode.theName ) ;
353 aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ;
354 if ( anInNode->IsOneOfInLineNodes() || anInNode->IsMacroNode() ) {
355 anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
356 _Orb , aNode.theService , anInNode->NamePtr() ,
358 _prof_debug , _fdebug ) ;
359 GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
360 GraphBase::LoopNode * aLNode = NULL ;
361 if ( aINode->IsLoopNode() ) {
362 aLNode = anInNode->LoopNode() ;
363 aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
364 *aNode.theListOfPythonFunctions[ 0 ] ) ;
365 aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
366 *aNode.theListOfPythonFunctions[ 1 ] ) ;
367 aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
368 *aNode.theListOfPythonFunctions[ 2 ] ) ;
370 else if ( aINode->IsMacroNode() || aINode->IsInLineNode() || aINode->IsGOTONode() ||
371 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
372 aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
373 *aNode.theListOfPythonFunctions[ 0 ] ) ;
377 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
378 GraphBase::InPort * anInPort ;
379 if ( anInNode->IsOneOfInLineNodes() ) {
380 anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
381 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
382 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
383 SUPERV::DataStreamParameter ) ;
386 anInPort = anInNode->ComputingNode()->GetChangeInPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ) ;
388 ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
389 aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
390 aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
392 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
393 GraphBase::OutPort * anOutPort ;
394 if ( anInNode->IsOneOfInLineNodes() ) {
395 anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
396 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
397 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
398 SUPERV::DataStreamParameter ) ;
401 anOutPort = anInNode->ComputingNode()->GetChangeOutPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ) ;
403 ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
405 delete aNodetheName ;
411 // setting coupled pairs of nodes: Loop-EndLoop, Switch-EndSwitch, InLine-GOTO, MacroNode-Graph
412 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
413 GraphBase::SNode aNode = aListOfNodes[ i ] ;
414 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
415 << aNode.theCoupledNode.c_str() << endl ;
416 anInNode = (GraphEditor::InNode * ) Graph()->GetChangeGraphNode( aMapOfNodes[ aNode.theName.c_str() ] )->GetInNode() ;
418 if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
419 GraphBase::GOTONode * aGOTONode;
420 aGOTONode = (GraphBase::GOTONode * ) anInNode->ComputingNode() ;
422 // asv : 25.10.04 : if aNode is a MacroNode, then its coupled node (another Graph) is NOT in aMapOfNodes
423 // and we must couple MacroNode only with name to its subgraph
424 if ( aGOTONode->IsMacroNode() ) {
425 cdebug << "GraphEditor::OutNode::LoadNodes MacroNode " << aNode.theName.c_str()
426 << " is Coupled ONLY WITH NAME to its subgraph " << aNode.theCoupledNode.c_str() << endl;
427 aGOTONode->CoupledNodeName( aNode.theCoupledNode.c_str() ) ;
429 else { // coupling Loop-EndLoop, Switch-EndSwitch, InLine-GOTO
430 // asv : fix for 6822 : using map because if aNode's name is the same as some existing node's name
431 // aMap will give the correct index any way (aMap has already a different name for aNode, SNode still has old name)
432 int aCoupledNodeIndex = aMapOfNodes[ aNode.theCoupledNode.c_str() ] ;
433 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theCoupledNode.c_str()
434 << " index " << aCoupledNodeIndex << endl ;
435 GraphBase::GOTONode * aCoupledNode ;
436 aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aCoupledNodeIndex ) ;
437 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str()
438 << " is now Coupled to " << aNode.theCoupledNode.c_str() << endl ;
439 aGOTONode->CoupledNode( aCoupledNode ) ;
443 cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
447 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
448 const GraphBase::ListOfSLinks &aListOfLinks ) {
451 cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
452 // MESSAGE( "GraphEditor::OutNode::LoadLinks" );
454 for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
455 GraphBase::SLink aLink = aListOfLinks[ i ] ;
456 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
457 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
458 cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( "
459 << aLink.FromServiceParameterName.c_str() << " ) --> "
460 << aLinkToNodeName->c_str() << "( "
461 << aLink.ToServiceParameterName.c_str() << " )" << endl ;
462 if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
463 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
464 //JR 08.02.2005 : Rule of CEA : a bad graph may be stored in a xml
465 RetAddLink = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
466 aLink.FromServiceParameterName.c_str() ,
467 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
468 aLink.ToServiceParameterName.c_str() ) ;
473 if ( RetVal && RetAddLink ) {
474 for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
475 RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
476 aLink.FromServiceParameterName.c_str() ,
477 Graph()->GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
478 aLink.ToServiceParameterName.c_str() ,
480 aLink.aListOfCoords[j].theX ,
481 aLink.aListOfCoords[j].theY ) ;
486 delete aLinkFromNodeName ;
487 delete aLinkToNodeName ;
489 cdebug_out << "GraphEditor::OutNode::LoadLinks " << RetVal << endl ;
493 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
494 const GraphBase::ListOfSLinks &aListOfDatas ) {
497 cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
498 // MESSAGE( "GraphEditor::OutNode::LoadDatas" );
500 for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
501 GraphBase::SLink aLink = aListOfDatas[ i ] ;
502 cdebug << "OutNode::LoadDatas " << i << aLink.FromNodeName.c_str() << "(" << aLink.FromServiceParameterName
503 << ") --> " << aLink.ToNodeName.c_str() << "(" << aLink.ToServiceParameterName << ") CORBA::tk_xxx "
504 << aLink.aLinkValue.type()->kind() << endl ;
505 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
506 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
507 // cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
508 // << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
509 // cout << " " << aLink.ToNodeName.c_str() << " "
510 // << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
511 RetAddLink = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
512 aLink.ToServiceParameterName.c_str() ,
514 delete aLinkFromNodeName ;
515 delete aLinkToNodeName ;
519 cdebug_out << "GraphEditor::OutNode::LoadDatas " << RetVal << endl ;
523 bool GraphEditor::OutNode::SaveXml(const char* filename) {
525 cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
526 ofstream f(filename);
528 QDomDocument DomGraph ;
529 QDomElement Domsupergraph ;
530 cdebug << "OutNode::SaveXML("<< filename << ") ---> OutNode::SaveXML( ostream & f , QDomDocument & , true "
531 << " , QDomElement & ) " << Graph()->Name() << endl ;
532 test = SaveXML( f , DomGraph , true , Domsupergraph );
533 QString xml = DomGraph.toString() ;
536 cdebug << "OutNode::SaveXML("<< filename << ") done" << endl ;
538 // QString xml = Graph.toString() ;
539 // cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
540 // f << xml << endl ;
542 cdebug_out << "GraphEditor::OutNode::SaveXml " << test << endl;
547 bool GraphEditor::OutNode::SavePy( const char* filename ) {
549 cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
550 ofstream f( filename ) ;
552 test = SavePY( f , true );
553 f << endl << Graph()->Name() << " = Def" << Graph()->Name() << "()" << endl ;
554 cdebug_out << "GraphEditor::OutNode::SavePy " << test << endl;
558 GraphBase::ListOfSGraphs * GraphEditor::OutNode::GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
559 // GraphBase::ListOfSGraphs * aListOfDataFlows = new GraphBase::ListOfSGraphs;
560 int index = aListOfDataFlows->size() ;
561 aListOfDataFlows->resize( index + 1 ) ;
562 if ( Graph()->IsDataFlowNode() ) {
563 (*aListOfDataFlows)[ index ].Info = *Graph()->GetInfo() ;
564 (*aListOfDataFlows)[ index ].Nodes = *Graph()->GetNodes() ;
565 (*aListOfDataFlows)[ index ].Links = *Graph()->GetLinks( true ) ;
566 (*aListOfDataFlows)[ index ].Datas = *Graph()->GetDatas() ;
569 (*aListOfDataFlows)[ index ].Info = *StreamGraph()->GetInfo() ;
570 (*aListOfDataFlows)[ index ].Nodes = *StreamGraph()->GetNodes() ;
571 (*aListOfDataFlows)[ index ].Links = *StreamGraph()->GetLinks( true ) ;
572 (*aListOfDataFlows)[ index ].Datas = *StreamGraph()->GetDatas() ;
575 for ( i = 0 ; i < (int ) (*aListOfDataFlows)[ index ].Nodes.size() ; i++ ) {
576 const GraphBase::ComputingNode * aNode = Graph()->GetGraphNode( (*aListOfDataFlows)[ index ].Nodes[i].theName.c_str() ) ;
577 if ( aNode->IsMacroNode() ) {
578 // string aCoupledNodeName = (*aListOfDataFlows)[ index ].Nodes[i].theCoupledNode ;
579 GraphBase::Graph * aGraph = (GraphBase::Graph * ) ((GraphBase::GOTONode * ) aNode )->CoupledNode() ;
580 // GraphBase::Graph * aGraph = MapGraph( aCoupledNodeName.c_str() ) ;
581 aGraph->GraphEditor()->GraphEditor::OutNode::GetDataFlows( aListOfDataFlows ) ;
584 return aListOfDataFlows ;
587 void GraphEditor::OutNode::DateModification() {
588 time_t T = time(NULL);
589 struct tm * Tm = localtime(&T);
590 SUPERV::SDate aLastModificationDate ;
592 aLastModificationDate.Second = Tm->tm_sec;
593 aLastModificationDate.Minute = Tm->tm_min;
594 aLastModificationDate.Hour = Tm->tm_hour;
595 aLastModificationDate.Day = Tm->tm_mday;
596 aLastModificationDate.Month = Tm->tm_mon + 1;
597 aLastModificationDate.Year = Tm->tm_year + 1900;
598 Graph()->LastModification( aLastModificationDate ) ;
601 void GraphEditor::OutNode::Coordinates( const char* NodeName ,
604 ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
607 const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
608 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->XCoordinate() ;
611 const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
612 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->YCoordinate() ;
615 GraphEditor::InNode * GraphEditor::OutNode::AddNode(
616 const SALOME_ModuleCatalog::Service& NodeService ,
617 GraphBase::ListOfFuncName aFuncName ,
618 GraphBase::ListOfPythonFunctions aPythonFunction ,
619 const char * NodeComponentName ,
620 const char * NodeInterfaceName ,
621 const char * theNodeName ,
622 const SUPERV::KindOfNode NodeKindOfNode ,
623 const SUPERV::SDate NodeFirstCreation ,
624 const SUPERV::SDate NodeLastModification ,
625 const char * NodeEditorRelease ,
626 const char * NodeAuthor ,
627 const char * NodeComputer ,
628 const char * NodeComment ,
631 cdebug_in << "GraphEditor::OutNode::AddNode( " ;
632 if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) {
633 cdebug << "Component('" << NodeComponentName << "') , Node('" ;
636 cdebug << "NodeComponentName[NULL] )" << endl;
638 if ( theNodeName == NULL ) {
639 theNodeName = NULLSTRING ;
641 if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) {
642 cdebug << theNodeName << "' )" ;
645 cdebug << "NodeName[NULLSTRING]' )" ;
647 cdebug << " " << NodeKindOfNode << endl ;
648 char * RetVal = NULLSTRING ;
649 GraphEditor::InNode *Nd = NULL ;
650 char * aNodeName = NULLSTRING ;
651 bool GeneratedName = false ;
652 //PAL9048 JR Debug : a node may not have the same name as the graph
653 bool GraphNodeSameName = false ;
654 if ( theNodeName && !strcmp( Graph()->Name() , theNodeName ) ) {
655 GraphNodeSameName = true ;
657 if ( NodeKindOfNode == SUPERV::InLineNode ||
658 NodeKindOfNode == SUPERV::LoopNode ||
659 NodeKindOfNode == SUPERV::EndLoopNode ||
660 NodeKindOfNode == SUPERV::SwitchNode ||
661 NodeKindOfNode == SUPERV::EndSwitchNode ||
662 NodeKindOfNode == SUPERV::GOTONode ) {
663 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
664 if ( NodeKindOfNode == SUPERV::InLineNode ) {
665 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
667 else if ( NodeKindOfNode == SUPERV::LoopNode ) {
668 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
670 else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
671 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
673 else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
674 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
676 else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
677 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
679 else if ( NodeKindOfNode == SUPERV::GOTONode ) {
680 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
684 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
686 theNodeName = NULLSTRING ;
688 //PAL9048 JR Debug : a node may not have the same name as the graph
689 // if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) {
690 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ||
691 Graph()->GetGraphNode( theNodeName ) || GraphNodeSameName ) {
692 cdebug << "OutNode::AddNode : '" << theNodeName << "' GraphNodeSameName "
693 << GraphNodeSameName << endl;
694 aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
695 strcpy( aNodeName , NodeService.ServiceName ) ;
696 // if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
697 if ( Graph()->GetGraphNode( NodeService.ServiceName ) || GraphNodeSameName ) {
698 GeneratedName = true ;
699 while ( Graph()->GetGraphNode( aNodeName ) || GraphNodeSameName ) {
700 cdebug << "OutNode::AddNode : '" << aNodeName << "' exists or GraphNodeSameName "
701 << GraphNodeSameName << endl;
703 delete [] aNodeName ;
705 //JR 09.08.2005 Debug : folowing line does not run with OMNIORB4
706 // char * aServiceName = (CORBA::String_member ) NodeService.ServiceName ;
707 int num = Graph()->GetNewServiceInstanceNumber( (CORBA::String_member ) NodeService.ServiceName ) ;
709 astr << num << ends ;
710 // const char * n_instance = astr.str().c_str() ;
711 int lname = strlen( NodeService.ServiceName ) + 1 +
712 strlen( astr.str().c_str() ) + 1 ;
713 aNodeName = new char[lname] ;
714 strcpy( aNodeName , NodeService.ServiceName ) ;
715 strcat( aNodeName , "_" ) ;
716 strcat( aNodeName , astr.str().c_str() ) ;
717 GraphNodeSameName = !strcmp( Graph()->Name() , aNodeName ) ;
722 if ( Graph()->GetGraphNode( theNodeName ) == NULL ) {
723 aNodeName = new char[ strlen( theNodeName )+1 ] ;
724 strcpy( aNodeName , theNodeName ) ;
727 aNodeName = NULLSTRING ;
730 if ( aNodeName != NULLSTRING ) {
731 Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() ,
732 aFuncName , aPythonFunction , NodeService ,
733 NodeComponentName , NodeInterfaceName ,
734 aNodeName , NodeKindOfNode ,
735 NodeFirstCreation , NodeLastModification ,
736 NodeEditorRelease , NodeAuthor ,
737 NodeComputer , NodeComment , GeneratedName ,
739 _prof_debug , _fdebug ) ;
741 // asv: 28.09.04 fix for 6621
742 //if ( Nd->IsMacroNode() )
743 // MapGraph( Nd->GraphMacroNode(), aNodeName );
745 if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) {
747 for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
748 GraphBase::InDataStreamPort * aDataStreamPort ;
749 aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
750 //JR 17.02.2005 Memory Leak my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
751 NodeService.ServiceinDataStreamParameter[i].Parametername ,
752 NodeService.ServiceinDataStreamParameter[i].Parametertype ,
753 NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
754 SUPERV::DataStreamParameter ) ;
756 for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
757 GraphBase::OutDataStreamPort * aDataStreamPort ;
758 aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
759 //JR 17.02.2005 Memory Leak my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
760 NodeService.ServiceoutDataStreamParameter[i].Parametername ,
761 NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
762 NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
763 SUPERV::DataStreamParameter ) ;
767 if ( Graph()->AddNode( Nd->ComputingNode() ) ) {
769 RetVal = Nd->Name() ;
772 cdebug << "NodeName already exists." << endl ;
776 cdebug << "ERROR NodeName is NULL or already exists." << endl ;
778 // delete [] aNodeName ;
781 cdebug_out << "GraphEditor::OutNode::AddNode : NULL" << endl;
784 cdebug_out << "GraphEditor::OutNode::AddNode : " << Nd << " " << Nd->Name() << endl;
789 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
790 const char* FromServiceParameterName ,
791 const char* ToNodeName ,
792 const char* ToServiceParameterName ,
796 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
797 ToServiceParameterName ) ;
798 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
799 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
801 if ( anInPort->IsEndSwitch() ) {
802 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
804 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
807 return anInPort->AddCoord( nXY , X , Y ) ;
813 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
814 const char* FromServiceParameterName ,
815 const char* ToNodeName ,
816 const char* ToServiceParameterName ,
820 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
821 ToServiceParameterName ) ;
822 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
823 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
825 if ( anInPort->IsEndSwitch() ) {
826 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
828 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
831 return anInPort->AddCoord( index , X , Y ) ;
837 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
838 const char* FromServiceParameterName ,
839 const char* ToNodeName ,
840 const char* ToServiceParameterName ,
844 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
845 ToServiceParameterName ) ;
846 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
847 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
849 if ( anInPort->IsEndSwitch() ) {
850 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
852 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
855 return anInPort->ChangeCoord( index , X , Y ) ;
861 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
862 const char* FromServiceParameterName ,
863 const char* ToNodeName ,
864 const char* ToServiceParameterName ,
866 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
867 ToServiceParameterName ) ;
868 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
869 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
871 if ( anInPort->IsEndSwitch() ) {
872 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
874 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
877 return anInPort->RemoveCoord( index ) ;
883 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
884 const char* FromServiceParameterName ,
885 const char* ToNodeName ,
886 const char* ToServiceParameterName ) {
887 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
888 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
889 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
891 if ( anInPort->IsEndSwitch() ) {
892 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
894 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
897 return anInPort->GetCoord() ;
903 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
904 const char* FromServiceParameterName ,
905 const char* ToNodeName ,
906 const char* ToServiceParameterName ,
908 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , 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( X , Y ) ;
918 return anInPort->GetCoord( X , Y ) ;
924 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
925 const char* FromServiceParameterName ,
926 const char* ToNodeName ,
927 const char* ToServiceParameterName ,
928 const int index , long &X , long &Y ) {
929 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
930 ToServiceParameterName ) ;
931 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
932 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
934 if ( anInPort->IsEndSwitch() ) {
935 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
937 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
940 return anInPort->GetCoord( index , X , Y ) ;
946 bool GraphEditor::OutNode::UnValid() {
947 bool RetVal = _Valid ;
949 if ( Graph()->GraphMacroLevel() != 0 ) {
950 cdebug << "GraphEditor::OutNode::UnValid() GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
956 //JR Optional parameter kLoopSwitch (default = true) :
957 //In some cases we do not need to check the validity of loops and switchs
958 //JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
959 //bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) {
960 bool GraphEditor::OutNode::Valid() {
962 cdebug_in << "GraphEditor::OutNode::Valid" << endl;
966 _Executable = false ;
968 if ( !Graph()->CreateService() ) {
969 cdebug << "GraphEditor::OutNode::Valid ERROR _Valid " << _Valid << endl;
973 if ( Graph()->GraphMacroLevel() != 0 ) {
974 cdebug << "CoupledNode " << Graph()->CoupledNode() << endl ;
975 cdebug << "GraphEditor " << Graph()->CoupledNode()->GraphEditor() << endl ;
976 cdebug << "Graph " << Graph()->CoupledNode()->GraphEditor()->Graph() << endl ;
977 cdebug << "Name " << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
978 cdebug << "Valid --> UpdateMacroPorts of " << Graph()->CoupledNodeName() << " of "
979 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
980 cdebug << Graph()->CoupledNode() << endl ;
981 Graph()->CoupledNode()->UpdateMacroPorts( Graph() ) ;
982 cdebug << Graph()->CoupledNode()->Name() << " Valid --> UnValid of graph "
983 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name()
984 << " GraphMacroLevel " << Graph()->CoupledNode()->GraphEditor()->Graph()->GraphMacroLevel() << endl ;
985 Graph()->CoupledNode()->GraphEditor()->UnValid() ;
988 Graph()->InLineServices() ;
990 //JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
992 int SubStreamGraphsNumber = 0 ;
993 if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
994 cdebug_out << "This DataFlow is not valid." << endl ;
997 if ( Graph()->IsDataStreamNode() ) {
998 StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
1001 //JR Debug 24.08.2005 : InLineServices is needed for Export ==> it is executed above
1002 // Graph()->InLineServices() ;
1004 if ( kLoopSwitch ) {
1005 if ( !Graph()->ValidLoops() ) {
1006 cdebug_out << "This DataFlow have not valid Loops." << endl ;
1009 if ( !Graph()->ValidSwitchs() ) {
1010 cdebug_out << "This DataFlow have not valid Switchs." << endl ;
1015 Graph()->ComputingNodes() ;
1022 cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << " RetVal " << RetVal << endl;
1026 bool GraphEditor::OutNode::Executable() {
1027 cdebug_in << "GraphEditor::OutNode::Executable" << endl;
1028 bool RetVal = true ;
1030 // LinkLoopNodes manage input values of LoopNodes and EndLoopNodes
1031 if ( Graph()->LinkLoopNodes( NewLink ) ) {
1038 cdebug << "Editor::OutNode::Executable This DataFlow is not executable(LinkLoopNodes)." << endl ;
1039 _Executable = false ;
1049 //JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
1050 bool IsValid = true;
1051 int SubStreamGraphsNumber = 0 ;
1052 if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
1053 cdebug << "Editor::OutNode::Executable This DataFlow is not valid(Sort)." << endl ;
1055 //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
1058 if ( Graph()->IsDataStreamNode() )
1059 StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
1061 Graph()->InLineServices() ;
1063 // if ( kLoopSwitch ) {
1064 if ( !Graph()->ValidLoops() ) {
1065 cdebug << "Editor::OutNode::Executable This DataFlow have not valid Loops(ValidLoops)." << endl ;
1067 //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
1070 if ( !Graph()->ValidSwitchs() ) {
1071 cdebug << "Editor::OutNode::Executable This DataFlow have not valid Switchs(ValidSwitchs)." << endl ;
1073 //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
1078 Graph()->ComputingNodes() ;
1080 if ( Graph()->DataServerNodes() )
1081 _Executable = true ;
1083 cdebug << "Editor::OutNode::Executable This DataFlow is not executable(DataServerNodes)." << endl ;
1084 _Executable = false ;
1088 if ( _Executable && Graph()->IsDataStreamNode() ) {
1089 StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
1092 // asv : 13.12.04 : introducing check for compatibility of linked ports' types.
1093 if ( !IsLinksCompatible() ) {
1094 _Executable = false;
1098 //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
1099 if ( !IsValid ) _Executable = false ;
1101 cdebug_out << "GraphEditor::OutNode::Executable _Executable " << _Executable << " RetVal " << RetVal
1106 //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetInData(
1107 const CORBA::Any GraphEditor::OutNode::GetInData(
1108 const char * ToNodeName ,
1109 const char * ToParameterName ) {
1110 // cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
1111 // << " " << ToParameterName << endl ;
1112 //JR 30.03.2005 const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1113 const CORBA::Any retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1114 // cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
1118 //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetOutData(
1119 const CORBA::Any GraphEditor::OutNode::GetOutData(
1120 const char * FromNodeName ,
1121 const char * FromParameterName ) {
1122 // cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
1123 // << " " << FromParameterName << endl ;
1124 //JR 30.03.2005 const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1125 const CORBA::Any retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1126 // cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
1130 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
1131 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
1132 GraphBase::SLink aLink ,
1133 bool wdata ) const {
1134 cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1135 << "(" << aLink.FromServiceParameterName << ") --> "
1136 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ;
1137 QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
1139 if ( strlen( aLink.FromNodeName.c_str() ) ) {
1140 // f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
1141 // << "</fromnode-name>" << endl ;
1142 aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
1145 // f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
1146 aField = Graph.createTextNode( "?" ) ;
1148 link.appendChild( fromnodename ) ;
1149 fromnodename.appendChild( aField ) ;
1151 // f << Tabs << "<fromserviceparameter-name>"
1152 // << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
1154 QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
1155 aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
1156 link.appendChild( fromserviceparametername ) ;
1157 fromserviceparametername.appendChild( aField ) ;
1159 QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
1160 if ( strlen( aLink.ToNodeName.c_str() ) ) {
1161 // f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
1162 // << "</tonode-name>" << endl ;
1163 aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
1166 // f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
1167 aField = Graph.createTextNode( "?" ) ;
1169 link.appendChild( tonodename ) ;
1170 tonodename.appendChild( aField ) ;
1172 // f << Tabs << "<toserviceparameter-name>"
1173 // << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
1175 QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
1176 aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
1177 link.appendChild( toserviceparametername ) ;
1178 toserviceparametername.appendChild( aField ) ;
1181 // f << Tabs << "<data-value>" << endl ;
1182 QDomElement datavalue = Graph.createElement( "data-value" ) ;
1183 link.appendChild( datavalue ) ;
1184 // f << Tabs << " <value-type>" << aLink.aLinkValue.type()->kind()
1185 // << "</value-type>" << endl ;
1186 QDomElement valuetype = Graph.createElement( "value-type" ) ;
1188 aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
1189 aField = Graph.createTextNode( aKind ) ;
1190 datavalue.appendChild( valuetype ) ;
1191 valuetype.appendChild( aField ) ;
1192 switch (aLink.aLinkValue.type()->kind()) {
1193 case CORBA::tk_string: {
1195 aLink.aLinkValue >>= retstr;
1196 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1197 QDomElement value = Graph.createElement( "value" ) ;
1198 //PAL9133 Debug JR : accept void strings
1199 QDomCDATASection aCDATA ;
1201 for ( i = 0 ; i < (int ) strlen( retstr ) ; i++ ) {
1202 if ( retstr[ i ] != ' ' ) {
1206 if ( i == (int ) strlen( retstr ) ) {
1207 aCDATA = Graph.createCDATASection( "?" ) ;
1210 aCDATA = Graph.createCDATASection( retstr ) ;
1212 // aField = Graph.createTextNode( retstr ) ;
1213 datavalue.appendChild( value ) ;
1214 // datavalue.appendChild( value ) ;
1215 value.appendChild( aCDATA ) ;
1216 // MESSAGE( "ToString( string ) " << retstr );
1219 case CORBA::tk_double: {
1221 aLink.aLinkValue >>= d;
1222 // f << Tabs << " <value>" << d << "</value>" << endl ;
1223 QDomElement value = Graph.createElement( "value" ) ;
1225 aKind = aKind.setNum( d ) ;
1226 aField = Graph.createTextNode( aKind ) ;
1227 datavalue.appendChild( value ) ;
1228 value.appendChild( aField ) ;
1229 // MESSAGE( "ToString( double ) " << d );
1232 case CORBA::tk_long: {
1234 aLink.aLinkValue >>= l;
1235 // f << Tabs << " <value>" << l << "</value>" << endl ;
1236 QDomElement value = Graph.createElement( "value" ) ;
1238 aKind = aKind.setNum( l ) ;
1239 aField = Graph.createTextNode( aKind ) ;
1240 datavalue.appendChild( value ) ;
1241 value.appendChild( aField ) ;
1242 // MESSAGE( "ToString( long ) " << l );
1245 case CORBA::tk_objref: {
1247 CORBA::Object_ptr obj ;
1248 aLink.aLinkValue >>= obj ;
1249 retstr = _Orb->object_to_string(obj );
1250 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1251 QDomElement value = Graph.createElement( "value" ) ;
1252 aField = Graph.createTextNode( retstr ) ;
1253 datavalue.appendChild( value ) ;
1254 value.appendChild( aField ) ;
1255 // MESSAGE( "ToString( object ) " << retstr );
1259 // f << Tabs << " <value>?</value>" << endl ;
1260 QDomElement value = Graph.createElement( "value" ) ;
1261 aField = Graph.createTextNode( "?" ) ;
1262 datavalue.appendChild( value ) ;
1263 value.appendChild( aField ) ;
1264 // MESSAGE( "Unknown CORBA::Any Type" );
1268 // f << Tabs << "</data-value>" << endl ;
1270 // f << Tabs << "<coord-list>" << endl ;
1271 QDomElement coordlist = Graph.createElement( "coord-list" ) ;
1272 link.appendChild( coordlist ) ;
1275 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1276 // f << Tabs << " <coord>" << endl ;
1277 QDomElement coord = Graph.createElement( "coord" ) ;
1278 coordlist.appendChild( coord ) ;
1279 // f << Tabs << " <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
1280 QDomElement x = Graph.createElement( "x" ) ;
1282 ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
1283 aField = Graph.createTextNode( ax ) ;
1284 coord.appendChild( x ) ;
1285 x.appendChild( aField ) ;
1286 // f << Tabs << " <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
1287 QDomElement y = Graph.createElement( "y" ) ;
1289 ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
1290 aField = Graph.createTextNode( ay ) ;
1291 coord.appendChild( y ) ;
1292 y.appendChild( aField ) ;
1293 // f << Tabs << " </coord>" << endl ;
1295 // f << Tabs << "</coord-list>" << endl ;
1296 cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1297 << "(" << aLink.FromServiceParameterName << ") --> "
1298 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")"
1303 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
1304 GraphBase::SLink aLink ,
1305 bool fromparam , bool toparam ,
1306 bool wdata ) const {
1308 // if ( intervar ) {
1309 // f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1311 // << aLink.FromNodeName.c_str() << ".GetOutPort( '"
1312 // << aLink.FromServiceParameterName.c_str()
1313 // << "' )" << endl ;
1315 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1316 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ;
1317 if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) {
1318 f << " = " << aGraphName << ".StreamLink( " ;
1321 f << " = " << aGraphName << ".Link( " ;
1323 // if ( !fromparam ) {
1326 f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ;
1327 // if ( !toparam ) {
1330 f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ;
1333 f << " " << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
1334 // << " = " << aLink.ToNodeName.c_str() << ".Input( '"
1335 // << aLink.ToServiceParameterName.c_str() << "' , " ;
1337 switch (aLink.aLinkValue.type()->kind()) {
1338 case CORBA::tk_string: {
1340 aLink.aLinkValue >>= retstr;
1341 f << "'" << retstr << "'" ;
1344 case CORBA::tk_double: {
1346 aLink.aLinkValue >>= d;
1350 case CORBA::tk_long: {
1352 aLink.aLinkValue >>= l;
1356 case CORBA::tk_objref: {
1358 CORBA::Object_ptr obj ;
1359 aLink.aLinkValue >>= obj ;
1360 retstr = _Orb->object_to_string(obj );
1361 f << "'" << retstr << "'" ;
1366 // MESSAGE( "Unknown CORBA::Any Type" );
1373 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1374 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1375 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
1376 << aLink.aListOfCoords[ i ].theX << " , "
1377 << aLink.aListOfCoords[ i ].theY << " )" << endl ;
1382 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
1383 bool GraphEditor::OutNode::SaveXML( ostream & f , QDomDocument & GraphQDom ,
1384 bool aSuperGraph , QDomElement & supergraph ) {
1385 cdebug_in << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1386 << Graph()->Name() << endl ;
1389 QDomElement dataflow ;
1390 if ( aSuperGraph ) {
1391 QString SuperGraph("SuperGraph") ;
1392 GraphQDom = QDomDocument(SuperGraph) ;
1394 supergraph = GraphQDom.createElement( "supergraph" ) ;
1395 GraphQDom.appendChild( supergraph ) ;
1397 dataflow = GraphQDom.createElement( "dataflow" ) ;
1398 supergraph.appendChild( dataflow ) ;
1401 // QString Dataflow("Dataflow") ;
1402 // GraphQDom = QDomDocument(Dataflow) ;
1404 dataflow = GraphQDom.createElement( "dataflow" ) ;
1405 supergraph.appendChild( dataflow ) ;
1408 QDomElement info = GraphQDom.createElement( "info-list" ) ;
1409 dataflow.appendChild( info ) ;
1411 Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ;
1413 QDomElement nodelist = GraphQDom.createElement( "node-list" ) ;
1414 dataflow.appendChild( nodelist ) ;
1415 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1416 // f << " <node>" << endl ;
1417 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1418 // ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
1420 ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1421 Graph()->GraphNodes( i )->XCoordinate() ,
1422 Graph()->GraphNodes( i )->YCoordinate() ) ;
1424 else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1425 // ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1427 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1428 Graph()->GraphNodes( i )->XCoordinate() ,
1429 Graph()->GraphNodes( i )->YCoordinate() ) ;
1431 else if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1432 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1434 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1435 Graph()->GraphNodes( i )->XCoordinate() ,
1436 Graph()->GraphNodes( i )->YCoordinate() ) ;
1438 else if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1439 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1441 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1442 Graph()->GraphNodes( i )->XCoordinate() ,
1443 Graph()->GraphNodes( i )->YCoordinate() ) ;
1445 else if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1446 // ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1448 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1449 Graph()->GraphNodes( i )->XCoordinate() ,
1450 Graph()->GraphNodes( i )->YCoordinate() ) ;
1452 else if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1453 // ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1455 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1456 Graph()->GraphNodes( i )->XCoordinate() ,
1457 Graph()->GraphNodes( i )->YCoordinate() ) ;
1459 else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) {
1460 // ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1462 ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1463 Graph()->GraphNodes( i )->XCoordinate() ,
1464 Graph()->GraphNodes( i )->YCoordinate() ) ;
1466 else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1467 // ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1469 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1470 Graph()->GraphNodes( i )->XCoordinate() ,
1471 Graph()->GraphNodes( i )->YCoordinate() ) ;
1473 else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) {
1474 // ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1476 ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1477 Graph()->GraphNodes( i )->XCoordinate() ,
1478 Graph()->GraphNodes( i )->YCoordinate() ) ;
1480 // f << " </node>" << endl ;
1483 // f << " </node-list>" << endl << endl ;
1485 // f << " <link-list>" << endl ;
1486 QDomElement linklist = GraphQDom.createElement( "link-list" ) ;
1487 dataflow.appendChild( linklist ) ;
1488 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1489 for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1490 // f << " <link>" << endl ;
1491 QDomElement link = GraphQDom.createElement( "link" ) ;
1492 linklist.appendChild( link ) ;
1493 // LinkSaveXML( f , " " , (*Links)[ i ] , false ) ;
1494 LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ;
1495 // f << " </link>" << endl ;
1497 // f << " </link-list>" << endl << endl ;
1499 // f << " <data-list>" << endl ;
1500 QDomElement datalist = GraphQDom.createElement( "data-list" ) ;
1501 dataflow.appendChild( datalist ) ;
1502 if ( Graph()->GraphMacroLevel() == 0 ) {
1503 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1504 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1505 // f << " <data>" << endl ;
1506 QDomElement data = GraphQDom.createElement( "data" ) ;
1507 datalist.appendChild( data ) ;
1508 // LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ;
1509 LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ;
1510 // f << " </data>" << endl ;
1514 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1515 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1516 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1517 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1518 cdebug << "OutNode::SaveXML ---> OutNode::SaveXML( ostream & f , QDomDocument & , false "
1519 << " , QDomElement & ) MacroGraph " << aMacroGraph->Name() << endl ;
1520 if ( !aMacroGraph->GraphEditor()->SaveXML( f , GraphQDom , false , supergraph ) ) {
1522 cdebug << "OutNode::SaveXML MacroGraph "<< aMacroGraph->Name() << " done" << endl ;
1527 cdebug_out << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1528 << Graph()->Name() << endl ;
1533 bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
1536 const GraphBase::ListOfSLinks * Links ;
1537 if ( importSuperV ) {
1538 f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
1540 f << "from SuperV import *" << endl << endl ;
1543 f << "# Graph creation of " << Graph()->Name() << endl ;
1544 f << "def Def" << Graph()->Name() << "() :" << endl ;
1545 Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ;
1547 f << " " << endl << " " << "# Creation of Factory Nodes" << endl ;
1548 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1549 if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1551 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1552 Graph()->GraphNodes( i )->XCoordinate() ,
1553 Graph()->GraphNodes( i )->YCoordinate() ) ;
1558 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1559 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1561 f << " " << endl << " " << "# Creation of Computing Nodes" << endl ;
1567 ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1568 Graph()->GraphNodes( i )->XCoordinate() ,
1569 Graph()->GraphNodes( i )->YCoordinate() ) ;
1574 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1575 if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1577 f << " " << endl << " " << "# Creation of InLine Nodes" << endl ;
1583 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1584 Graph()->GraphNodes( i )->XCoordinate() ,
1585 Graph()->GraphNodes( i )->YCoordinate() ) ;
1590 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1591 if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1593 f << " " << endl << " " << "# Creation of Loop Nodes" << endl ;
1599 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1600 Graph()->GraphNodes( i )->XCoordinate() ,
1601 Graph()->GraphNodes( i )->YCoordinate() ) ;
1606 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1607 if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1609 f << " " << endl << " " << "# Creation of Switch Nodes" << endl ;
1615 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1616 Graph()->GraphNodes( i )->XCoordinate() ,
1617 Graph()->GraphNodes( i )->YCoordinate() ) ;
1622 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1623 if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1625 f << " " << endl << " " << "# Creation of GOTO Nodes" << endl ;
1631 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1632 Graph()->GraphNodes( i )->XCoordinate() ,
1633 Graph()->GraphNodes( i )->YCoordinate() ) ;
1638 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1639 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1641 f << " " << endl << " " << "# Creation of Macro Nodes" << endl ;
1647 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1648 Graph()->GraphNodes( i )->XCoordinate() ,
1649 Graph()->GraphNodes( i )->YCoordinate() ) ;
1653 Links = Graph()->GetLinks() ;
1655 // map< string , int > aMapOfOutPorts ;
1657 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1658 for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1659 if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1662 << " " << "# Creation of Links"
1669 // char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1670 // strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1671 // strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1672 // strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1673 // if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1674 // aMapOfOutPorts[ NodePort ] = j + 1 ;
1675 // intervar = true ;
1678 // intervar = false ;
1680 bool fromparam = false ;
1681 if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) {
1684 bool toparam = false ;
1685 if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) {
1688 LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ;
1689 // delete [] NodePort ;
1694 if ( Graph()->GraphMacroLevel() == 0 ) {
1695 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1697 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1699 f << " " << endl << " " << "# Input datas" << endl ;
1702 bool fromparam = true ;
1703 bool toparam = true ;
1704 LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ;
1709 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ;
1710 for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1711 string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1712 const char * aParam = _aParam.c_str() ;
1716 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1717 // if ( aParam[ j ] == '\\' ) {
1718 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1719 aNodeName = new char[ j+1 ] ;
1720 strncpy( aNodeName , aParam , j ) ;
1721 aNodeName[ j ] = '\0' ;
1722 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1723 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1727 const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ;
1728 if ( !anInPort->IsDataConnected() ) {
1730 f << " " << endl << " " << "# Input Ports of the graph" << endl ;
1733 f << " " << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '"
1734 << aPortName << "' )" << endl ;
1736 delete [] aNodeName ;
1737 delete [] aPortName ;
1740 f << " " << endl << " # Output Ports of the graph" << endl ;
1741 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ;
1742 for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1743 string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1744 const char * aParam = _aParam.c_str() ;
1748 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1749 // if ( aParam[ j ] == '\\' ) {
1750 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1751 aNodeName = new char[ j+1 ] ;
1752 strncpy( aNodeName , aParam , j ) ;
1753 aNodeName[ j ] = '\0' ;
1754 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1755 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1759 f << " " << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '"
1760 << aPortName << "' )" << endl ;
1761 delete [] aNodeName ;
1762 delete [] aPortName ;
1765 f << " " << "return " << Graph()->Name() << endl << endl ;
1767 // RECURSIVE CREATION OF GRAPHS OF MACRONODES
1768 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1769 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1770 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1771 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1772 cdebug << "OutNode::SavePY ---> OutNode::SavePY( ostream & f ) MacroGraph " << aMacroGraph->Name() << endl ;
1773 GraphEditor::DataFlow * aDataFlow = aMacroGraph->GraphEditor() ;
1774 cdebug << "SavePY of the Graph " << aDataFlow->Graph() << " of the MacroNode "
1775 << aMacroGraph->Name() << endl ;
1776 if ( !aDataFlow->SavePY( f , false ) ) {
1782 // f << Graph()->Name() << " = " << Graph()->Name() << "()" << endl ;
1787 /** Iterate through ALL links (OutPort-InPort pairs) and check if their types are
1788 * compatible - call GraphEditor::DataFlow::IsCompatible(type1, type2).
1789 * Returns true if all are compatible.
1791 bool GraphEditor::OutNode::IsLinksCompatible() {
1792 cdebug_in << "Editor::OutNode::IsLinksCompatible()" << endl ;
1795 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1796 cdebug_in << "Editor::OutNode::IsLinksCompatible() " << Links->size() << " Links" << endl ;
1797 // for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) {
1798 for ( int i = 0 ; i < (int ) Links->size() ; i++ ) {
1799 GraphBase::SLink aLink = (*Links)[i];
1800 GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() );
1801 GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() );
1802 const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() );
1803 const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() );
1804 b = IsCompatible( anOutPort->PortType(), anInPort->PortType() );
1805 cdebug << "GraphEditor::OutNode::IsLinksCompatible: " << aLink.FromNodeName << "( "
1806 << aLink.FromServiceParameterName << " " << anOutPort->PortType()
1807 << " ) --> " << aLink.ToNodeName <<"( " << aLink.ToServiceParameterName << " "
1808 << anInPort->PortType() << " ) = " << (b ? "OK" : "Not compatible (ERROR)") << endl;
1811 MESSAGE( "Graph structure ERROR: type of port \"" << aLink.FromServiceParameterName
1812 << "\" of node \"" << aLink.FromNodeName
1813 << "\" is not compatible with type of linked port \""
1814 << aLink.ToServiceParameterName << "\" of node \"" << aLink.ToNodeName<<"\"" ) ;
1815 ostringstream aTypeOutPortstr ;
1816 aTypeOutPortstr << anOutPort->PortType() ;
1817 ostringstream aTypeInPortstr ;
1818 aTypeInPortstr << anInPort->PortType() ;
1819 string anErrorMessage = string( "PortTypes of " ) + string( aLink.FromNodeName ) +
1820 string( "( " ) + aLink.FromServiceParameterName +
1821 string( " ) " ) + aTypeOutPortstr.str() + string( " and " ) +
1822 string( aLink.ToNodeName ) + string( "( " ) +
1823 string( aLink.ToServiceParameterName ) +
1824 string( " ) " ) + aTypeInPortstr.str() +
1825 string( " are not compatibles.\n" ) ;
1826 Graph()->SetMessages( anErrorMessage ) ;
1829 cdebug_out << "Editor::OutNode::IsLinksCompatible() RetVal " << RetVal << endl ;
1833 static const char* gSimpleTypes[] =
1834 {"boolean", "char", "short", "int", "long", "float", "double"};
1835 bool isSimpleType( string type ) {
1836 for ( int i = 0; i < 7; i++ )
1837 if ( type == gSimpleTypes[i] )
1842 /**Returns true if an out-port of type "OutPortType" can be bound with in-port of type "InPortType".
1843 * Types: {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"};
1844 * Currently considered compatible ALL types except for objref - they must match exactly
1846 bool GraphEditor::OutNode::IsCompatible( const char* OutPortType, const char* InPortType ) const {
1848 string t1 = OutPortType;
1849 string t2 = InPortType;
1850 // if ANY is a string - the link is OK
1851 if ( t1 == "string" || t2 == "string" )
1854 // the next check prohibits linkage of "objref" to any simple type (int, char, etc.)
1855 // it is still possible to link "objref" to some UNKNOWN type (probably objref, too,
1856 // which interface name came from Cataloge
1857 else if ( ( t1 == "objref" && isSimpleType( t2 ) ) ||
1858 ( t2 == "objref" && isSimpleType( t1 ) ) )
1863 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1864 f << (GraphBase::ComputingNode ) *(G.Graph()) ;
1867 f << " Nodes : " << (G.Graph())->GraphNodesSize() << " node"
1868 << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl;
1871 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1873 // << hex << (void *) G.Graph().GraphNodes( i ) << dec << " "
1874 << (G.Graph())->GraphNodes( i ) << endl;
1877 f << " Links : " << endl ;
1878 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1879 (G.Graph())->GraphNodes( i )->ListLinks( f ) ;
1882 f << " Datas : " << endl ;
1883 (G.Graph())->ListDatas( f ) ;
1885 f << "DataFlow " << (G.Graph())->Name() << " is " ;
1886 if ( G.IsNotValid() )
1888 f << "valid and is " ;
1889 if ( G.IsNotExecutable() )
1891 f << "executable." << endl ;
1898 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1900 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1902 fOut << D.Day << "/"
1909 // cdebug_out << "operator<< GraphEditor::Date" << endl;
1914 GraphBase::Graph * GraphEditor::OutNode::MapGraph( const char * aGraphName ) {
1915 GraphBase::Graph * aGraph = _MapOfGraphs[ aGraphName ] ;
1919 bool GraphEditor::OutNode::MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) {
1920 if ( MapGraph( aGraphName ) ) {
1923 _MapOfGraphs[ aGraphName ] = aGraph ;
1927 void GraphEditor::OutNode::EraseGraph( const char * aGraphName ) {
1928 _MapOfGraphs.erase( aGraphName ) ;
1931 bool GraphEditor::OutNode::GraphName( const char * aGraphName ) {
1932 return _MapOfGraphNames[ aGraphName ] ;