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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_Port.hxx
25 // Author : Jean Rahuel, CEA
29 #ifndef _DATAFLOWBASE_PORT_HXX
30 #define _DATAFLOWBASE_PORT_HXX
35 #include "DataFlowBase_ServicesParameter.hxx"
39 class Port : public ServicesParameter {
43 const char *const * _NodeName ;
44 SUPERV::Port_var _Port ;
45 SUPERV::KindOfPort _KindOfPort ;
50 SALOME_ModuleCatalog::DataStreamDependency _Dependency ; // Time or Iteration only for DataStreamPorts
56 _Port = SUPERV::Port::_nil() ;
57 _KindOfPort = SUPERV::UndefinedParameter ;
58 _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ; } ;
59 Port( const char *const * NodeName ,
60 const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
61 const SUPERV::KindOfPort aKindOfPort = SUPERV::ServiceParameter ,
62 const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) :
63 ServicesParameter( aserviceParameter ) {
64 _NodeName = NodeName ;
65 _Port = SUPERV::Port::_nil() ;
66 _KindOfPort = aKindOfPort ;
67 if ( IsDataStream() ) {
68 _Dependency = aDependency ;
71 _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ;
74 cdebug << "~Port" << endl ; } ;
76 SUPERV::Port_var ObjRef() const { return _Port ; } ;
77 void ObjRef(SUPERV::Port_var aPort) {
80 const char * NodeName() const { return *_NodeName ; } ;
81 const char * NodePortName() const {
82 // cout << "NodePortName " << hex << (void *) _NodeName << " "
83 // << dec << _NodeName << endl ;
84 char * _NodePortName = new char [ strlen( *_NodeName ) +
85 strlen( ServicesParameterName() ) + 4 ] ;
86 strcpy( _NodePortName , *_NodeName ) ;
87 // strcat( _NodePortName , "\\" ) ;
88 strcat( _NodePortName , "__" ) ;
89 strcat( _NodePortName , ServicesParameterName() ) ;
90 return _NodePortName ; } ;
92 const char * PortName() const {
95 return ServicesParameterName() ; } ;
96 const char * PortType() const { return ServicesParameterType() ; } ;
98 void PortType(char * aParametertype ) { ServicesParameterType( aParametertype ) ; } ;
99 void Kind( SUPERV::KindOfPort aKindOfPort ) {
100 if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) {
101 cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort
104 _KindOfPort = aKindOfPort ; } ;
105 const SUPERV::KindOfPort Kind() const {
106 return _KindOfPort ; } ;
107 bool IsParam() const {
108 return _KindOfPort == SUPERV::ServiceParameter ; } ;
109 bool IsGate() const {
110 return _KindOfPort == SUPERV::GateParameter ||
111 _KindOfPort == SUPERV::GOTOParameter ; } ;
112 bool IsInLine() const {
113 return _KindOfPort == SUPERV::InLineParameter ; } ;
114 bool IsLoop() const {
115 return _KindOfPort == SUPERV::LoopParameter ; } ;
116 bool IsSwitch() const {
117 return _KindOfPort == SUPERV::SwitchParameter ; } ;
118 bool IsEndSwitch() const {
119 return _KindOfPort == SUPERV::EndSwitchParameter ; } ;
120 bool IsGOTO() const {
121 return _KindOfPort == SUPERV::GOTOParameter ; } ;
122 bool IsDataStream() const {
123 return _KindOfPort == SUPERV::DataStreamParameter ; } ;
125 const SALOME_ModuleCatalog::DataStreamDependency Dependency() const {
126 return _Dependency ; } ;
127 bool Dependency( SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
128 if ( IsDataStream() ) {
129 _Dependency = aDependency ;
134 bool AddCoord( const int nxy , const int *x , const int *y ) ;
135 bool AddCoord( const int index , const int x , const int y ) ;
136 bool ChangeCoord( const int index ,
139 bool RemoveCoord( const int index ) ;
140 bool RemoveCoords() ;
141 int GetCoord() const ;
142 bool GetCoord( int *x , int *y ) const ;
143 const GraphBase::ListOfCoords * Coords() const ;
144 bool GetCoord( const int index , long &x , long &y ) const ;
150 ostream & operator<< (ostream &,const SUPERV::KindOfPort &);
152 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamDependency &);
154 ostream & operator<< (ostream &,const StatusOfPort &);