Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / src / GraphBase / DataFlowBase_DataNode.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_DataNode.cxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 using namespace std;
30 #include "DataFlowBase_DataNode.hxx"
31
32 GraphBase::DataNode::DataNode() :
33            InLineNode() {
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            InLineNode( ORB , ptrNamingService , DataFlowName ) {
42 //  MESSAGE( "GraphBase::DataNode::DataNode" );
43   cdebug << "GraphBase::DataNode::DataNode" << endl ;
44   _Created = false ;
45 }
46
47 GraphBase::DataNode::DataNode(
48                 CORBA::ORB_ptr ORB ,
49                 SALOME_NamingService* ptrNamingService ,
50                 const SALOME_ModuleCatalog::Service& DataFlowService ,
51                 const char *DataFlowName ,
52                 const SUPERV::KindOfNode DataFlowkind ,
53                 const SUPERV::SDate DataFlowFirstCreation ,
54                 const SUPERV::SDate DataFlowLastModification ,
55                 const char * DataFlowEditorRelease ,
56                 const char * DataFlowAuthor ,
57                 const char * DataFlowComment ) :
58            InLineNode( ORB , ptrNamingService , DataFlowService ,
59                        DataFlowName , DataFlowkind ,
60                        DataFlowFirstCreation , DataFlowLastModification  ,
61                        DataFlowEditorRelease , DataFlowAuthor ,
62                        DataFlowComment , false , 0 , 0) {
63 //  MESSAGE( "GraphBase::DataNode::DataNode" );
64 }
65
66 GraphBase::DataNode::~DataNode() {
67 //  MESSAGE( "GraphBase::DataNode::~DataNode" );
68 }
69
70 void GraphBase::DataNode::DataService( CORBA::ORB_ptr ORB ,
71                                        SALOME_ModuleCatalog::Service aService ,
72                                        int * Graph_prof_debug ,
73                                        ofstream * Graph_fdebug ) {
74   cdebug << "GraphBase::DataNode::DataService : DataFlowPortsOfNode of "
75          << aService.ServiceName << endl ;
76   DefPortsOfNode( ORB , aService , NamePtr() , Kind() ,
77                   Graph_prof_debug , Graph_fdebug ) ;
78
79   if ( _Created )
80     delete _DataFlowDataPorts ;
81   SALOME_ModuleCatalog::Service aReversedService ;
82   aReversedService.ServiceName = aService.ServiceName ;
83   aReversedService.ServiceinParameter = aService.ServiceoutParameter ;
84   aReversedService.ServiceoutParameter = aService.ServiceinParameter ;
85   _DataFlowDataPorts = new PortsOfNode() ;
86   cdebug << "GraphBase::DataNode::DataService : Mirrored DataFlowPortsOfNode of "
87          << aReversedService.ServiceName << endl ;
88   _DataFlowDataPorts->DefPortsOfNode( ORB , aReversedService , NamePtr() , Kind() ,
89                                       Graph_prof_debug , Graph_fdebug ) ;
90   _Created = true ;
91 }
92
93 int GraphBase::DataNode::CheckDataServerNodes() const {
94
95   cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
96
97   int i , ierr = 0 ;
98
99   for ( i = 0 ; i < _DataFlowDataPorts->GetNodeOutPortsSize() ; i++ ) {
100 // Not a BUG : Reversed Service of the graph 
101     const GraphBase::OutPort * anOutPort = _DataFlowDataPorts->GetNodeOutPort(i) ;
102 //    if ( !anOutPort->IsGate() && !anOutPort->IsDataStream() && !anOutPort->IsDataConnected() ) {
103     if ( !anOutPort->IsGate() && !anOutPort->IsDataConnected() ) {
104       cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType()
105              << " of DataFlow " << Name() << " has NO Data." << endl ;
106       ierr++ ;
107     }
108     else {
109       cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType()
110              << " of DataFlow " << Name()  << " has Data : "
111 //           << _DataFlowDataPorts->GetNodeOutPort(i)->Value() << " kind "
112 //           << _DataFlowDataPorts->GetNodeOutPort(i)->Kind()
113              << endl ;
114     }
115   }
116
117   for ( i = 0 ; i < _DataFlowDataPorts->GetNodeInPortsSize() ; i++ ) {
118     if ( !_DataFlowDataPorts->GetNodeInPort(i)->IsConnected() ) {
119       cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName()
120              << " of DataFlow " << Name()  << " has Data " << endl ;
121 //      ierr++ ;
122     }
123     else {
124       cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName()
125              << " of DataFlow " << Name()  << " has NO Data : "
126 //           << _DataFlowDataPorts->GetChangeNodeInPort(i)->GetLink()->Value()
127 //           << " kind "
128 //           << _DataFlowDataPorts->GetChangeNodeInPort(i)->GetLink()->Kind()
129              << endl ;
130       ierr++ ;
131     }
132   }
133
134   if ( ierr ) {
135     cdebug << "Some Input Data missing in the DataFlow " << Name() << endl ;
136   }
137
138   return ierr ;
139 }
140
141 void GraphBase::DataNode::ListDatas(ostream & f ) const {
142   _DataFlowDataPorts->ListPorts( f , false ) ;
143 }
144
145 void GraphBase::DataNode::DataNodeInfo(ostream & s ) const {
146   s << *this ;
147   s << "Ports :" << endl ;
148   ListPorts( s , true ) ;
149   s << "Datas :" << endl ;
150   _DataFlowDataPorts->ListPorts( s , false ) ;
151   s << ends ;
152 }
153
154 // inlined :
155 //GraphBase::OutPort * GraphBase::DataNode::GetChangeInDataNodePort( const char * DataFlowInPortName ) {
156 //  return _DataFlowDataPorts->GetChangeOutPort( DataFlowInPortName ) ;
157 //}
158
159 //GraphBase::InPort * GraphBase::DataNode::GetChangeOutDataNodePort( const char * DataFlowOutPortName ) {
160 //  return _DataFlowDataPorts->GetChangeInPort( DataFlowOutPortName ) ;
161 //}
162