Salome HOME
96cf474f10918cf4c31245fee41829988ee917eb
[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   _Created = false ;
44 }
45
46 GraphBase::DataNode::DataNode(
47                 CORBA::ORB_ptr ORB ,
48                 SALOME_NamingService* ptrNamingService ,
49                 const SALOME_ModuleCatalog::Service& DataFlowService ,
50                 const char *DataFlowName ,
51                 const SUPERV::KindOfNode DataFlowkind ,
52                 const SUPERV::SDate DataFlowFirstCreation ,
53                 const SUPERV::SDate DataFlowLastModification ,
54                 const char * DataFlowEditorRelease ,
55                 const char * DataFlowAuthor ,
56                 const char * DataFlowComment ) :
57            InLineNode( ORB , ptrNamingService , DataFlowService ,
58                        DataFlowName , DataFlowkind ,
59                        DataFlowFirstCreation , DataFlowLastModification  ,
60                        DataFlowEditorRelease , DataFlowAuthor ,
61                        DataFlowComment , false , 0 , 0) {
62 //  MESSAGE( "GraphBase::DataNode::DataNode" );
63 }
64
65 GraphBase::DataNode::~DataNode() {
66 //  MESSAGE( "GraphBase::DataNode::~DataNode" );
67 }
68
69 void GraphBase::DataNode::DataService(
70                        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() ,
89                                       Kind() ,
90                                       Graph_prof_debug , Graph_fdebug ) ;
91   _Created = true ;
92 }
93
94 int GraphBase::DataNode::CheckDataServerNodes() const {
95
96   cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
97
98   int i , ierr = 0 ;
99
100   for ( i = 0 ; i < _DataFlowDataPorts->GetNodeOutPortsSize() ; i++ ) {
101     if ( !_DataFlowDataPorts->GetNodeOutPort(i)->IsDataConnected() ) {
102       cdebug << "InPort " << _DataFlowDataPorts->GetNodeOutPort(i)->PortName()
103              << " of DataFlow " << Name() << " has NO Data." << endl ;
104       ierr++ ;
105     }
106     else {
107       cdebug << "InPort " << _DataFlowDataPorts->GetNodeOutPort(i)->PortName()
108              << " of DataFlow " << Name()  << " has Data : "
109 //           << _DataFlowDataPorts->GetNodeOutPort(i)->Value() << " kind "
110 //           << _DataFlowDataPorts->GetNodeOutPort(i)->Kind()
111              << endl ;
112     }
113   }
114
115   for ( i = 0 ; i < _DataFlowDataPorts->GetNodeInPortsSize() ; i++ ) {
116     if ( !_DataFlowDataPorts->GetNodeInPort(i)->IsConnected() ) {
117       cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName()
118              << " of DataFlow " << Name()  << " has Data " << endl ;
119 //      ierr++ ;
120     }
121     else {
122       cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName()
123              << " of DataFlow " << Name()  << " has NO Data : "
124 //           << _DataFlowDataPorts->GetChangeNodeInPort(i)->GetLink()->Value()
125 //           << " kind "
126 //           << _DataFlowDataPorts->GetChangeNodeInPort(i)->GetLink()->Kind()
127              << endl ;
128       ierr++ ;
129     }
130   }
131
132   if ( ierr ) {
133     cdebug << "Some Input Data missing in the DataFlow " << Name() << endl ;
134   }
135
136   return ierr ;
137 }
138
139 void GraphBase::DataNode::ListDatas(ostream & f ) const {
140   _DataFlowDataPorts->ListPorts( f , false ) ;
141 }
142
143 void GraphBase::DataNode::DataNodeInfo(ostream & s ) const {
144   s << *this ;
145   s << "Ports :" << endl ;
146   ListPorts( s , true ) ;
147   s << "Datas :" << endl ;
148   _DataFlowDataPorts->ListPorts( s , false ) ;
149   s << ends ;
150 }
151
152 // inlined :
153 //GraphBase::OutPort * GraphBase::DataNode::GetChangeInDataNodePort( const char * DataFlowInPortName ) {
154 //  return _DataFlowDataPorts->GetChangeOutPort( DataFlowInPortName ) ;
155 //}
156
157 //GraphBase::InPort * GraphBase::DataNode::GetChangeOutDataNodePort( const char * DataFlowOutPortName ) {
158 //  return _DataFlowDataPorts->GetChangeInPort( DataFlowOutPortName ) ;
159 //}
160