1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : DataFlowBase_Port.cxx
8 // Author : Jean Rahuel, CEA
13 #include "DataFlowBase_Port.hxx"
15 //GraphBase::Port::~Port() {
16 // cout << "Port::~Port()" << endl ;
19 bool GraphBase::Port::AddCoord( const int nxy , const int *x ,
22 if ( IsEndSwitch() ) {
28 for ( i = 0 ; i < nxy ; i++ ) {
36 bool GraphBase::Port::AddCoord( const int index ,
37 const int x , const int y ) {
38 if ( IsEndSwitch() ) {
42 if ( index <= 0 || index > (int ) _X.size()+1 )
44 _X.resize( _X.size()+1 ) ;
45 _Y.resize( _Y.size()+1 ) ;
47 for ( i = _X.size() - 1 ; i >= index ; i-- ) {
53 // cdebug << "AddCoord " << NodeName() << "(" << PortName() << ") ["
54 // << index-1 << "] " << x << " " << y << endl ;
55 // for ( i = 0 ; i < _X.size() ; i++ ) {
56 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
62 bool GraphBase::Port::ChangeCoord( const int index ,
65 if ( IsEndSwitch() ) {
69 if ( index <= 0 || index > (int ) _X.size() )
73 // cdebug << "ChangeCoord " << NodeName() << "(" << PortName() << ") ["
74 // << index-1 << "] " << x << " " << y << endl ;
76 // for ( i = 0 ; i < _X.size() ; i++ ) {
77 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
83 bool GraphBase::Port::RemoveCoord( const int index ) {
84 if ( IsEndSwitch() ) {
88 if ( index <= 0 || index > (int ) _X.size() )
91 for ( i = index - 1 ; i < (int ) _X.size() - 1 ; i++ ) {
95 _X.resize( _X.size()-1 ) ;
96 _Y.resize( _Y.size()-1 ) ;
101 bool GraphBase::Port::RemoveCoords() {
102 if ( IsEndSwitch() ) {
112 int GraphBase::Port::GetCoord() const {
114 if ( IsEndSwitch() ) {
123 bool GraphBase::Port::GetCoord( int *x , int *y ) const {
125 if ( IsEndSwitch() ) {
129 for ( i = 0 ; i < (int ) _X.size() ; i++ ) {
137 const GraphBase::ListOfCoords * GraphBase::Port::Coords() const {
138 GraphBase::ListOfCoords * _list_Coords = new GraphBase::ListOfCoords ;
140 if ( !IsEndSwitch() ) {
141 _list_Coords->resize( _X.size() );
142 for ( i = 0 ; i < (int ) _X.size() ; i++ ) {
143 (*_list_Coords)[ i ].theX = _X[ i ] ;
144 (*_list_Coords)[ i ].theY = _Y[ i ] ;
147 return _list_Coords ;
150 bool GraphBase::Port::GetCoord( const int index , long &x , long &y ) const {
151 if ( IsEndSwitch() ) {
155 if ( index <= 0 || index > (int ) _X.size() )
157 x = _X[ index - 1 ] ;
158 y = _Y[ index - 1 ] ;
159 // cdebug << "GetCoord " << NodeName() << "(" << PortName() << ") ["
160 // << index-1 << "] " << x << " " << y << endl ;
162 // for ( i = 0 ; i < _X.size() ; i++ ) {
163 // cdebug << " [" << i << "] " << _X[ i ] << " " << _Y[ i ] << endl ;
169 ostream & operator<< (ostream & f ,const SUPERV::KindOfPort & s ) {
171 case SUPERV::UndefinedParameter :
172 f << "UndefinedParameter";
174 case SUPERV::ServiceParameter :
175 f << "ServiceParameter";
177 case SUPERV::GateParameter :
178 f << "GateParameter";
180 case SUPERV::InLineParameter :
181 f << "InLineParameter";
183 case SUPERV::LoopParameter :
184 f << "LoopParameter";
186 case SUPERV::SwitchParameter :
187 f << "SwitchParameter";
189 case SUPERV::EndSwitchParameter :
190 f << "EndSwitchParameter";
192 case SUPERV::GOTOParameter :
193 f << "GOTOParameter";
195 case SUPERV::DataStreamParameter :
196 f << "DataStreamParameter";
199 f << "UnknownKindOfPort";
206 ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::DataStreamDependency & s ) {
208 case SALOME_ModuleCatalog::DATASTREAM_UNDEFINED :
209 f << "DATASTREAM_UNDEFINED";
211 case SALOME_ModuleCatalog::DATASTREAM_TEMPORAL :
212 f << "DATASTREAM_TEMPORAL";
214 case SALOME_ModuleCatalog::DATASTREAM_ITERATIVE :
215 f << "DATASTREAM_ITERATIVE";
225 ostream & operator<< (ostream & f ,const StatusOfPort & s ) {
231 f << "PortConnected";
233 // case PortAndDataConnected :
234 // f << "PortAndDataConnected";
237 f << "DataConnected";
239 case ExternConnected :
240 f << "ExternConnected";
243 f << "UnknownStatusOfPort";