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 // cdebug << "Port::Port _NodeName " << _NodeName << " = " << (void * ) *_NodeName
66 // << " = " << _NodeName << " in Port " << PortName() << endl ;
67 _Port = SUPERV::Port::_nil() ;
68 _KindOfPort = aKindOfPort ;
69 if ( IsDataStream() ) {
70 _Dependency = aDependency ;
73 _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ;
76 cdebug << "~Port _NodeName " << *_NodeName << endl ; } ;
78 SUPERV::Port_var ObjRef() const { return _Port ; } ;
79 void ObjRef(SUPERV::Port_var aPort) {
82 const char * NodeName() const {
83 // cdebug << "Port::NodeName _NodeName " << _NodeName << " = " << (void * ) *_NodeName
84 // << " = " << *_NodeName << " in Port " << PortName() << endl ;
85 return *_NodeName ; } ;
86 const char * NodePortName() const {
87 // cout << "NodePortName " << hex << (void *) _NodeName << " "
88 // << dec << _NodeName << endl ;
89 char * _NodePortName = new char [ strlen( *_NodeName ) +
90 strlen( ServicesParameterName() ) + 4 ] ;
91 strcpy( _NodePortName , *_NodeName ) ;
92 // strcat( _NodePortName , "\\" ) ;
93 strcat( _NodePortName , "__" ) ;
94 strcat( _NodePortName , ServicesParameterName() ) ;
95 return _NodePortName ; } ;
97 const char * PortName() const {
100 return ServicesParameterName() ; } ;
101 const char * PortType() const { return ServicesParameterType() ; } ;
103 void PortType(char * aParametertype ) { ServicesParameterType( aParametertype ) ; } ;
104 void Kind( SUPERV::KindOfPort aKindOfPort ) {
105 if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) {
106 cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort
109 _KindOfPort = aKindOfPort ; } ;
110 const SUPERV::KindOfPort Kind() const {
111 return _KindOfPort ; } ;
112 bool IsParam() const {
113 return _KindOfPort == SUPERV::ServiceParameter ; } ;
114 bool IsGate() const {
115 return _KindOfPort == SUPERV::GateParameter ||
116 _KindOfPort == SUPERV::GOTOParameter ; } ;
117 bool IsInLine() const {
118 return _KindOfPort == SUPERV::InLineParameter ; } ;
119 bool IsLoop() const {
120 return _KindOfPort == SUPERV::LoopParameter ; } ;
121 bool IsSwitch() const {
122 return _KindOfPort == SUPERV::SwitchParameter ; } ;
123 bool IsEndSwitch() const {
124 return _KindOfPort == SUPERV::EndSwitchParameter ; } ;
125 bool IsGOTO() const {
126 return _KindOfPort == SUPERV::GOTOParameter ; } ;
127 bool IsDataStream() const {
128 return _KindOfPort == SUPERV::DataStreamParameter ; } ;
130 const SALOME_ModuleCatalog::DataStreamDependency Dependency() const {
131 return _Dependency ; } ;
132 bool Dependency( SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
133 if ( IsDataStream() ) {
134 _Dependency = aDependency ;
139 bool AddCoord( const int nxy , const int *x , const int *y ) ;
140 bool AddCoord( const int index , const int x , const int y ) ;
141 bool ChangeCoord( const int index ,
144 bool RemoveCoord( const int index ) ;
145 bool RemoveCoords() ;
146 int GetCoord() const ;
147 bool GetCoord( int *x , int *y ) const ;
148 const GraphBase::ListOfCoords * Coords() const ;
149 bool GetCoord( const int index , long &x , long &y ) const ;
155 ostream & operator<< (ostream &,const SUPERV::KindOfPort &);
157 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamDependency &);
159 ostream & operator<< (ostream &,const StatusOfPort &);