Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[modules/superv.git] / src / GraphBase / DataFlowBase_EndOfSwitchNode.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : DataFlowBase_EndOfSwitchNode.cxx
8 //  Author : Jean Rahuel, CEA
9 //  Module : SUPERV
10 //  $Header:
11
12 using namespace std;
13 //#include <sstream>
14 //#include <iostream>
15
16 #include "DataFlowBase_EndOfSwitchNode.hxx"
17
18 GraphBase::EndOfSwitchNode::EndOfSwitchNode() :
19   GraphBase::GOTONode::GOTONode() {
20
21   cdebug << "GraphBase::EndOfSwitchNode::EndOfSwitchNode "  << this 
22          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
23          << (void *) Comment() << " "  << Comment() << " "  << endl ;
24
25 }
26
27 GraphBase::EndOfSwitchNode::EndOfSwitchNode( CORBA::ORB_ptr ORB ,
28                                    SALOME_NamingService* ptrNamingService ,
29                                    const char * FuncName ,
30                                    const SUPERV::ListOfStrings & aPythonFunction ,
31                                    const char *NodeName ,
32                                    const SUPERV::KindOfNode akind ,
33                                    const SUPERV::SDate NodeFirstCreation ,
34                                    const SUPERV::SDate NodeLastModification  ,
35                                    const char * NodeEditorRelease ,
36                                    const char * NodeAuthor ,
37                                    const char * NodeComment ,
38                                    const bool   GeneratedName ,
39                                    const long   X ,
40                                    const long   Y ,
41                                    int * Graph_prof_debug ,
42                                    ofstream * Graph_fdebug ) :
43   GraphBase::GOTONode::GOTONode( ORB , ptrNamingService , FuncName ,
44                                  aPythonFunction ,
45                                  NodeName , akind , NodeFirstCreation ,
46                                  NodeLastModification  , NodeEditorRelease ,
47                                  NodeAuthor , NodeComment , GeneratedName ,
48                                  X , Y , Graph_prof_debug , Graph_fdebug ) {
49
50   cdebug_in << "GraphBase::EndOfSwitchNode::EndOfSwitchNode "  << this 
51             << "' _Name " << (void *) Name() << " '" << Name() << " _Comment "
52             << (void *) Comment() << " "  << Comment() << " " 
53             << " KindOfNode " << Kind() << " FuncName " << FuncName
54             << " ServiceName " << ServiceName() << " In("
55             << ServiceInParameter().length()
56             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
57
58   cdebug_out << "GraphBase::EndOfSwitchNode::EndOfSwitchNode" << endl;
59 }
60
61 GraphBase::EndOfSwitchNode::~EndOfSwitchNode() {
62   cdebug << "GraphBase::EndOfSwitchNode::~EndOfSwitchNode "  << this 
63          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
64          << (void *) Comment() << " "  << Comment() << " "  << endl ;
65 //  if ( _ComponentName != NULLSTRING )
66 //    delete [] _ComponentName ;
67 //  delete [] _Name ;
68 //  delete [] _EditorRelease ;
69 //  if ( _Author != NULLSTRING )
70 //    delete [] _Author ;
71 //  if ( _Computer != FACTORYSERVER )
72 //    delete [] _Computer;
73 //  if ( _Comment != NULLSTRING )
74 //    delete [] _Comment;
75 }
76
77 bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ) {
78   bool RetVal = true ;
79 //  if ( !anInPort->BranchOfSwitchLinked() ) {
80     RetVal = anInPort->BranchOfSwitchLinked( true ) ;
81 //JR 16.02.2005 : except for DefaultPort
82     if ( !anInPort->IsGate() ) {
83       _EndSwitchInPortLinkedNumber -= 1 ;
84     }
85     cdebug << Name()
86            << "->EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber "
87            << _EndSwitchInPortLinkedNumber << " InPort '" << anInPort->PortName() << "' of "
88            << anInPort->NodeName() << " RetVal " << RetVal << endl ;
89 //  }
90 //  else {
91 //    cdebug << "EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber "
92 //           << _EndSwitchInPortLinkedNumber << " InPort " << anInPort->PortName()
93 //           << " already done RetVal " << RetVal << endl ;
94 //  }
95   return RetVal ;
96 }
97
98 bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked() {
99 // Check that all inports of the EndSwitchNode will have a value only once
100   if ( _EndSwitchInPortLinkedNumber != 0 ) {
101     cdebug << Name()
102            << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked EndSwitchInPortLinkedNumber "
103            << _EndSwitchInPortLinkedNumber << endl ;
104     if ( !SwitchWithGOTO() ) {
105       return false ; // Some InPort is not linked
106     }
107   }
108 // Check that all inports of the EndSwitchNode are reachable in that branch(es)
109   int i ;
110   for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
111     if ( !GetChangeNodeInPort( i )->IsDataStream() &&
112          !GetChangeNodeInPort( i )->BranchOfSwitchLinked() ) {
113       cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked "
114              << GetNodeInPort( i )->PortName() << " have no link in that branch"
115              << endl ;
116       if ( !SwitchWithGOTO() ) {
117         return false ; // that InPort is not linked
118       }
119     }
120   }
121   return true ; // Ok : all InPorts are linked
122 }