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.hxx
24 // Author : Jean Rahuel, CEA
28 #ifndef _DATAFLOWBASE_PORT_HXX
29 #define _DATAFLOWBASE_PORT_HXX
34 #include "DataFlowBase_ServicesParameter.hxx"
38 class Port : public ServicesParameter {
42 const char *const * _NodeName ;
43 SUPERV::Port_var _Port ;
44 SUPERV::KindOfPort _KindOfPort ;
49 SALOME_ModuleCatalog::DataStreamDependency _Dependency ; // Time or Iteration only for DataStreamPorts
55 _Port = SUPERV::Port::_nil() ;
56 _KindOfPort = SUPERV::UndefinedParameter ;
57 _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ; } ;
58 Port( const char *const * NodeName ,
59 const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
60 const SUPERV::KindOfPort aKindOfPort = SUPERV::ServiceParameter ,
61 const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) :
62 ServicesParameter( aserviceParameter ) {
63 _NodeName = NodeName ;
64 // cdebug << "Port::Port _NodeName " << _NodeName << " = " << (void * ) *_NodeName
65 // << " = " << _NodeName << " in Port " << PortName() << endl ;
66 _Port = SUPERV::Port::_nil() ;
67 _KindOfPort = aKindOfPort ;
68 if ( IsDataStream() ) {
69 _Dependency = aDependency ;
72 _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ;
75 cdebug << "~Port _NodeName " << *_NodeName << endl ; } ;
77 SUPERV::Port_var ObjRef() const { return _Port ; } ;
78 void ObjRef(SUPERV::Port_var aPort) {
81 const char * NodeName() const {
82 // cdebug << "Port::NodeName _NodeName " << _NodeName << " = " << (void * ) *_NodeName
83 // << " = " << *_NodeName << " in Port " << PortName() << endl ;
84 return *_NodeName ; } ;
85 const char * NodePortName() const {
86 // cout << "NodePortName " << hex << (void *) _NodeName << " "
87 // << dec << _NodeName << endl ;
88 char * _NodePortName = new char [ strlen( *_NodeName ) +
89 strlen( ServicesParameterName() ) + 4 ] ;
90 strcpy( _NodePortName , *_NodeName ) ;
91 // strcat( _NodePortName , "\\" ) ;
92 strcat( _NodePortName , "__" ) ;
93 strcat( _NodePortName , ServicesParameterName() ) ;
94 return _NodePortName ; } ;
96 const char * PortName() const {
99 return ServicesParameterName() ; } ;
100 const char * PortType() const { return ServicesParameterType() ; } ;
102 void PortType(char * aParametertype ) { ServicesParameterType( aParametertype ) ; } ;
103 void Kind( SUPERV::KindOfPort aKindOfPort ) {
104 if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) {
105 cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort
108 _KindOfPort = aKindOfPort ; } ;
109 const SUPERV::KindOfPort Kind() const {
110 return _KindOfPort ; } ;
111 bool IsParam() const {
112 return _KindOfPort == SUPERV::ServiceParameter ; } ;
113 bool IsGate() const {
114 return _KindOfPort == SUPERV::GateParameter ||
115 _KindOfPort == SUPERV::GOTOParameter ; } ;
116 bool IsInLine() const {
117 return _KindOfPort == SUPERV::InLineParameter ; } ;
118 bool IsLoop() const {
119 return _KindOfPort == SUPERV::LoopParameter ; } ;
120 bool IsSwitch() const {
121 return _KindOfPort == SUPERV::SwitchParameter ; } ;
122 bool IsEndSwitch() const {
123 return _KindOfPort == SUPERV::EndSwitchParameter ; } ;
124 bool IsGOTO() const {
125 return _KindOfPort == SUPERV::GOTOParameter ; } ;
126 bool IsDataStream() const {
127 return _KindOfPort == SUPERV::DataStreamParameter ; } ;
129 const SALOME_ModuleCatalog::DataStreamDependency Dependency() const {
130 return _Dependency ; } ;
131 bool Dependency( SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
132 if ( IsDataStream() ) {
133 _Dependency = aDependency ;
138 bool AddCoord( const int nxy , const int *x , const int *y ) ;
139 bool AddCoord( const int index , const int x , const int y ) ;
140 bool ChangeCoord( const int index ,
143 bool RemoveCoord( const int index ) ;
144 bool RemoveCoords() ;
145 int GetCoord() const ;
146 bool GetCoord( int *x , int *y ) const ;
147 const GraphBase::ListOfCoords * Coords() const ;
148 bool GetCoord( const int index , CORBA::Long &x , CORBA::Long &y ) const ;
154 ostream & operator<< (ostream &,const SUPERV::KindOfPort &);
156 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamDependency &);
158 ostream & operator<< (ostream &,const StatusOfPort &);