1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
23 // File : DataFlowBase_Port.cxx
24 // Author : Jean Rahuel, CEA
28 #include "DataFlowBase_Port.hxx"
30 //GraphBase::Port::~Port() {
31 // cout << "Port::~Port()" << endl ;
34 bool GraphBase::Port::AddCoord( const int nxy , const int *x ,
37 if ( IsEndSwitch() ) {
43 for ( i = 0 ; i < nxy ; i++ ) {
51 bool GraphBase::Port::AddCoord( const int index ,
52 const int x , const int y ) {
53 if ( IsEndSwitch() ) {
57 if ( index <= 0 || index > (int ) _X.size()+1 )
59 _X.resize( _X.size()+1 ) ;
60 _Y.resize( _Y.size()+1 ) ;
62 for ( i = _X.size() - 1 ; i >= index ; i-- ) {
68 // cdebug << "AddCoord " << NodeName() << "(" << PortName() << ") ["
69 // << index-1 << "] " << x << " " << y << endl ;
70 // for ( i = 0 ; i < _X.size() ; i++ ) {
71 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
77 bool GraphBase::Port::ChangeCoord( const int index ,
80 if ( IsEndSwitch() ) {
84 if ( index <= 0 || index > (int ) _X.size() )
88 // cdebug << "ChangeCoord " << NodeName() << "(" << PortName() << ") ["
89 // << index-1 << "] " << x << " " << y << endl ;
91 // for ( i = 0 ; i < _X.size() ; i++ ) {
92 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
98 bool GraphBase::Port::RemoveCoord( const int index ) {
99 if ( IsEndSwitch() ) {
103 if ( index <= 0 || index > (int ) _X.size() )
106 for ( i = index - 1 ; i < (int ) _X.size() - 1 ; i++ ) {
107 _X[ i ] = _X[ i+1 ] ;
108 _Y[ i ] = _Y[ i+1 ] ;
110 _X.resize( _X.size()-1 ) ;
111 _Y.resize( _Y.size()-1 ) ;
116 bool GraphBase::Port::RemoveCoords() {
117 if ( IsEndSwitch() ) {
127 int GraphBase::Port::GetCoord() const {
129 if ( IsEndSwitch() ) {
138 bool GraphBase::Port::GetCoord( int *x , int *y ) const {
140 if ( IsEndSwitch() ) {
144 for ( i = 0 ; i < (int ) _X.size() ; i++ ) {
152 const GraphBase::ListOfCoords * GraphBase::Port::Coords() const {
153 GraphBase::ListOfCoords * _list_Coords = new GraphBase::ListOfCoords ;
155 if ( !IsEndSwitch() ) {
156 _list_Coords->resize( _X.size() );
157 for ( i = 0 ; i < (int ) _X.size() ; i++ ) {
158 (*_list_Coords)[ i ].theX = _X[ i ] ;
159 (*_list_Coords)[ i ].theY = _Y[ i ] ;
162 return _list_Coords ;
165 bool GraphBase::Port::GetCoord( const int index , CORBA::Long &x , CORBA::Long &y ) const {
166 if ( IsEndSwitch() ) {
170 if ( index <= 0 || index > (int ) _X.size() )
172 x = _X[ index - 1 ] ;
173 y = _Y[ index - 1 ] ;
174 // cdebug << "GetCoord " << NodeName() << "(" << PortName() << ") ["
175 // << index-1 << "] " << x << " " << y << endl ;
177 // for ( i = 0 ; i < _X.size() ; i++ ) {
178 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
184 ostream & operator<< (ostream & f ,const SUPERV::KindOfPort & s ) {
186 case SUPERV::UndefinedParameter :
187 f << "UndefinedParameter";
189 case SUPERV::ServiceParameter :
190 f << "ServiceParameter";
192 case SUPERV::GateParameter :
193 f << "GateParameter";
195 case SUPERV::InLineParameter :
196 f << "InLineParameter";
198 case SUPERV::LoopParameter :
199 f << "LoopParameter";
201 case SUPERV::SwitchParameter :
202 f << "SwitchParameter";
204 case SUPERV::EndSwitchParameter :
205 f << "EndSwitchParameter";
207 case SUPERV::GOTOParameter :
208 f << "GOTOParameter";
210 case SUPERV::DataStreamParameter :
211 f << "DataStreamParameter";
214 f << "UnknownKindOfPort";
221 ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::DataStreamDependency & s ) {
223 case SALOME_ModuleCatalog::DATASTREAM_UNDEFINED :
224 f << "DATASTREAM_UNDEFINED";
226 case SALOME_ModuleCatalog::DATASTREAM_TEMPORAL :
227 f << "DATASTREAM_TEMPORAL";
229 case SALOME_ModuleCatalog::DATASTREAM_ITERATIVE :
230 f << "DATASTREAM_ITERATIVE";
240 ostream & operator<< (ostream & f ,const StatusOfPort & s ) {
246 f << "PortConnected";
248 // case PortAndDataConnected :
249 // f << "PortAndDataConnected";
252 f << "DataConnected";
254 case ExternConnected :
255 f << "ExternConnected";
258 f << "UnknownStatusOfPort";