1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 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 // File : DataFlowBase_Port.cxx
23 // Author : Jean Rahuel, CEA
27 #include "DataFlowBase_Port.hxx"
29 //GraphBase::Port::~Port() {
30 // cout << "Port::~Port()" << endl ;
33 bool GraphBase::Port::AddCoord( const int nxy , const int *x ,
36 if ( IsEndSwitch() ) {
42 for ( i = 0 ; i < nxy ; i++ ) {
50 bool GraphBase::Port::AddCoord( const int index ,
51 const int x , const int y ) {
52 if ( IsEndSwitch() ) {
56 if ( index <= 0 || index > (int ) _X.size()+1 )
58 _X.resize( _X.size()+1 ) ;
59 _Y.resize( _Y.size()+1 ) ;
61 for ( i = _X.size() - 1 ; i >= index ; i-- ) {
67 // cdebug << "AddCoord " << NodeName() << "(" << PortName() << ") ["
68 // << index-1 << "] " << x << " " << y << endl ;
69 // for ( i = 0 ; i < _X.size() ; i++ ) {
70 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
76 bool GraphBase::Port::ChangeCoord( const int index ,
79 if ( IsEndSwitch() ) {
83 if ( index <= 0 || index > (int ) _X.size() )
87 // cdebug << "ChangeCoord " << NodeName() << "(" << PortName() << ") ["
88 // << index-1 << "] " << x << " " << y << endl ;
90 // for ( i = 0 ; i < _X.size() ; i++ ) {
91 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
97 bool GraphBase::Port::RemoveCoord( const int index ) {
98 if ( IsEndSwitch() ) {
102 if ( index <= 0 || index > (int ) _X.size() )
105 for ( i = index - 1 ; i < (int ) _X.size() - 1 ; i++ ) {
106 _X[ i ] = _X[ i+1 ] ;
107 _Y[ i ] = _Y[ i+1 ] ;
109 _X.resize( _X.size()-1 ) ;
110 _Y.resize( _Y.size()-1 ) ;
115 bool GraphBase::Port::RemoveCoords() {
116 if ( IsEndSwitch() ) {
126 int GraphBase::Port::GetCoord() const {
128 if ( IsEndSwitch() ) {
137 bool GraphBase::Port::GetCoord( int *x , int *y ) const {
139 if ( IsEndSwitch() ) {
143 for ( i = 0 ; i < (int ) _X.size() ; i++ ) {
151 const GraphBase::ListOfCoords * GraphBase::Port::Coords() const {
152 GraphBase::ListOfCoords * _list_Coords = new GraphBase::ListOfCoords ;
154 if ( !IsEndSwitch() ) {
155 _list_Coords->resize( _X.size() );
156 for ( i = 0 ; i < (int ) _X.size() ; i++ ) {
157 (*_list_Coords)[ i ].theX = _X[ i ] ;
158 (*_list_Coords)[ i ].theY = _Y[ i ] ;
161 return _list_Coords ;
164 bool GraphBase::Port::GetCoord( const int index , CORBA::Long &x , CORBA::Long &y ) const {
165 if ( IsEndSwitch() ) {
169 if ( index <= 0 || index > (int ) _X.size() )
171 x = _X[ index - 1 ] ;
172 y = _Y[ index - 1 ] ;
173 // cdebug << "GetCoord " << NodeName() << "(" << PortName() << ") ["
174 // << index-1 << "] " << x << " " << y << endl ;
176 // for ( i = 0 ; i < _X.size() ; i++ ) {
177 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
183 ostream & operator<< (ostream & f ,const SUPERV::KindOfPort & s ) {
185 case SUPERV::UndefinedParameter :
186 f << "UndefinedParameter";
188 case SUPERV::ServiceParameter :
189 f << "ServiceParameter";
191 case SUPERV::GateParameter :
192 f << "GateParameter";
194 case SUPERV::InLineParameter :
195 f << "InLineParameter";
197 case SUPERV::LoopParameter :
198 f << "LoopParameter";
200 case SUPERV::SwitchParameter :
201 f << "SwitchParameter";
203 case SUPERV::EndSwitchParameter :
204 f << "EndSwitchParameter";
206 case SUPERV::GOTOParameter :
207 f << "GOTOParameter";
209 case SUPERV::DataStreamParameter :
210 f << "DataStreamParameter";
213 f << "UnknownKindOfPort";
220 ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::DataStreamDependency & s ) {
222 case SALOME_ModuleCatalog::DATASTREAM_UNDEFINED :
223 f << "DATASTREAM_UNDEFINED";
225 case SALOME_ModuleCatalog::DATASTREAM_TEMPORAL :
226 f << "DATASTREAM_TEMPORAL";
228 case SALOME_ModuleCatalog::DATASTREAM_ITERATIVE :
229 f << "DATASTREAM_ITERATIVE";
239 ostream & operator<< (ostream & f ,const StatusOfPort & s ) {
245 f << "PortConnected";
247 // case PortAndDataConnected :
248 // f << "PortAndDataConnected";
251 f << "DataConnected";
253 case ExternConnected :
254 f << "ExternConnected";
257 f << "UnknownStatusOfPort";