]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_DataNode.cxx
Salome HOME
8d81b76c0f48121c6dbef7bbac3069101dc427f2
[modules/superv.git] / src / GraphBase / DataFlowBase_DataNode.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
23 //  File   : DataFlowBase_DataNode.cxx
24 //  Author : Jean Rahuel, CEA
25 //  Module : SUPERV
26 //  $Header:
27 //
28 using namespace std;
29 #include "DataFlowBase_DataNode.hxx"
30 #include "DataFlowBase_Graph.hxx"
31
32 GraphBase::DataNode::DataNode() :
33            GOTONode() {
34   MESSAGE( "GraphBase::DataNode::DataNode" );
35   _Created = false ;
36 }
37
38 GraphBase::DataNode::DataNode( CORBA::ORB_ptr ORB ,
39                                SALOME_NamingService* ptrNamingService ,
40                                const char *DataFlowName ,
41                                const SUPERV::KindOfNode DataFlowkind ,
42                                int * Graph_prof_debug ,
43                                ofstream * Graph_fdebug ) :
44            GOTONode( ORB , ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
45 //  MESSAGE( "GraphBase::DataNode::DataNode" );
46   cdebug << "GraphBase::DataNode::DataNode" << endl ;
47   _Created = false ;
48 }
49
50 GraphBase::DataNode::DataNode( CORBA::ORB_ptr ORB ,
51                                SALOME_NamingService* ptrNamingService ,
52                                const SALOME_ModuleCatalog::Service& DataFlowService ,
53                                const char *DataFlowName ,
54                                const SUPERV::KindOfNode DataFlowkind ,
55                                const SUPERV::SDate DataFlowFirstCreation ,
56                                const SUPERV::SDate DataFlowLastModification ,
57                                const char * DataFlowEditorRelease ,
58                                const char * DataFlowAuthor ,
59                                const char * DataFlowComment ) :
60            GOTONode( ORB , ptrNamingService ,
61                      DataFlowName , SUPERV::ListOfStrings() , DataFlowName , DataFlowkind ,
62                      DataFlowFirstCreation , DataFlowLastModification  ,
63                      DataFlowEditorRelease , DataFlowAuthor ,
64                      DataFlowComment , false , 0 , 0) {
65 //  MESSAGE( "GraphBase::DataNode::DataNode" );
66 }
67
68 GraphBase::DataNode::~DataNode() {
69 //  MESSAGE( "GraphBase::DataNode::~DataNode" );
70   cdebug << "GraphBase::DataNode::~DataNode" << endl ;
71 }
72
73 void GraphBase::DataNode::DataService( CORBA::ORB_ptr ORB ,
74                                        SALOME_ModuleCatalog::Service aService ,
75                                        int * Graph_prof_debug ,
76                                        ofstream * Graph_fdebug ) {
77   cdebug << "GraphBase::DataNode::DataService : DataFlowPortsOfNode of "
78          << aService << endl ;
79   DefPortsOfNode( ORB , aService , NamePtr() , Kind() ,
80                   Graph_prof_debug , Graph_fdebug ) ;
81
82   if ( _Created ) {
83     delete _DataFlowDataPorts ;
84   }
85   SALOME_ModuleCatalog::Service aReversedService ;
86   aReversedService.ServiceName = aService.ServiceName ;
87   aReversedService.ServiceinParameter = aService.ServiceoutParameter ;
88   aReversedService.ServiceoutParameter = aService.ServiceinParameter ;
89   _DataFlowDataPorts = new PortsOfNode() ;
90   cdebug << "GraphBase::DataNode::DataService : Mirrored DataFlowPortsOfNode of "
91          << aReversedService << endl ;
92   _DataFlowDataPorts->DefPortsOfNode( ORB , aReversedService , NamePtr() , Kind() ,
93                                       Graph_prof_debug , Graph_fdebug ) ;
94   _Created = true ;
95 }
96
97 int GraphBase::DataNode::CheckDataServerNodes() const {
98
99   cdebug_in << "GraphBase::DataNode::CheckDataServerNodes :" << endl;
100
101   int i , ierr = 0 ;
102
103   for ( i = 0 ; i < _DataFlowDataPorts->GetNodeOutPortsSize() ; i++ ) {
104 // Not a BUG : Reversed Service of the graph : OutPort of the Graph give input values to nodes
105     const GraphBase::OutPort * anOutPort = _DataFlowDataPorts->GetNodeOutPort(i) ;
106 //    if ( !anOutPort->IsGate() && !anOutPort->IsDataStream() && !anOutPort->IsDataConnected() ) {
107     if ( !anOutPort->IsGate() && !anOutPort->IsDataConnected() ) {
108       if ( anOutPort->IsExternConnected() && GraphMacroLevel() != 0 ) {
109         cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName() << " "
110                << anOutPort->PortType() << " "
111                << anOutPort->PortStatus() << " of DataFlow " << Name()
112                << " is ExternConnected. GraphMacroLevel " << GraphMacroLevel() << endl ;
113       }
114       else {
115         cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName() << " "
116                << anOutPort->PortType() << " " << anOutPort->PortStatus() << " of DataFlow " << Name()
117                << " has NO Data. GraphMacroLevel " << GraphMacroLevel() << " InPortsSize "
118                << anOutPort->InPortsSize() << " corresponding to :"
119                << endl ;
120         int i ;
121         for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) {
122           cdebug << "           " << anOutPort->InPorts( i )->NodeName() << "( "
123                  << anOutPort->InPorts( i )->PortName() << " ) " << endl ;
124         }
125         if ( anOutPort->InPortsSize() == 1 &&
126              GraphOfNode()->GetGraphNode( anOutPort->InPorts( 0 )->NodeName() )->IsEndSwitchNode() ) {
127           cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName()
128                  << " is connected to an EndSwitchNode. Input Data is controlled by ValidSwitchs."
129                  << endl ;
130         }
131         else {
132           ostringstream astr ;
133           astr << anOutPort->PortStatus() ;
134           string anErrorMessage = string( "InPort " ) + string( anOutPort->NodeName() ) +
135                                   string( "( " ) + string( anOutPort->PortName() ) + string( " ) " ) +
136                                   astr.str() + string( " has NO Input Data.\n" ) ;
137           GraphOfNode()->SetMessages( anErrorMessage ) ;
138           ierr++ ;
139         }
140       }
141     }
142     else {
143       cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName() << " "
144              << anOutPort->PortType() << " "
145              << anOutPort->PortStatus() << " of DataFlow " << Name()  << " has Data or IsGate"
146              << endl ;
147     }
148   }
149
150   for ( i = 0 ; i < _DataFlowDataPorts->GetNodeInPortsSize() ; i++ ) {
151     if ( _DataFlowDataPorts->GetNodeInPort(i)->IsPortConnected() ) {
152       cdebug << "Base::DataNode::CheckDataServerNodes OutPort "
153              << _DataFlowDataPorts->GetNodeInPort(i)->PortName()
154              << " of DataFlow " << Name()  << " is Connected" << endl ;
155     }
156     else {
157       cdebug << "Base::DataNode::CheckDataServerNodes OutPort "
158              << _DataFlowDataPorts->GetNodeInPort(i)->PortName()
159              << " of DataFlow " << Name()  << " is NOT Connected" << endl ;
160     }
161   }
162
163   if ( ierr ) {
164     GraphOfNode()->SetMessages( "Some Input Data are missing.\n" ) ;
165     cdebug << "Base::DataNode::CheckDataServerNodes In the DataFlow " << Name() << " " << ierr
166            << " Some Input Data are missing" << endl ;
167   }
168
169   cdebug_out << "GraphBase::DataNode::CheckDataServerNodes ierr " << ierr << endl;
170   return ierr ;
171 }
172
173 void GraphBase::DataNode::ListDatas(ostream & f ) const {
174   _DataFlowDataPorts->ListPorts( f , false ) ;
175 }
176
177 void GraphBase::DataNode::DataNodeInfo(ostream & s ) const {
178   s << *this ;
179   s << "Ports :" << endl ;
180   ListPorts( s , true ) ;
181   s << "Datas :" << endl ;
182   _DataFlowDataPorts->ListPorts( s , false ) ;
183   s << ends ;
184 }
185
186 // inlined :
187 //GraphBase::OutPort * GraphBase::DataNode::GetChangeInDataNodePort( const char * DataFlowInPortName ) {
188 //  return _DataFlowDataPorts->GetChangeOutPort( DataFlowInPortName ) ;
189 //}
190
191 //GraphBase::InPort * GraphBase::DataNode::GetChangeOutDataNodePort( const char * DataFlowOutPortName ) {
192 //  return _DataFlowDataPorts->GetChangeInPort( DataFlowOutPortName ) ;
193 //}
194