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 {
41 const char *const * _NodeName ;
42 SUPERV::Port_var _Port ;
43 SUPERV::KindOfPort _KindOfPort ;
51 // cout << "Port()" << endl ;
53 _Port = SUPERV::Port::_nil() ;
54 _KindOfPort = SUPERV::UndefinedParameter ;
56 Port( const char *const * NodeName ,
57 const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
58 const SUPERV::KindOfPort aKindOfPort = SUPERV::ServiceParameter ) :
59 ServicesParameter( aserviceParameter ) {
60 _NodeName = NodeName ;
61 _Port = SUPERV::Port::_nil() ;
62 _KindOfPort = aKindOfPort ;
65 cdebug << "~Port" << endl ; } ;
67 SUPERV::Port_var ObjRef() const { return _Port ; } ;
68 void ObjRef(SUPERV::Port_var aPort) {
71 const char * NodeName() const { return *_NodeName ; } ;
72 const char * NodePortName() const {
73 // cout << "NodePortName " << hex << (void *) _NodeName << " "
74 // << dec << _NodeName << endl ;
75 char * _NodePortName = new char [ strlen( *_NodeName ) +
76 strlen( ServicesParameterName() ) + 3 ] ;
77 strcpy( _NodePortName , *_NodeName ) ;
78 strcat( _NodePortName , "\\" ) ;
79 strcat( _NodePortName , ServicesParameterName() ) ;
80 // strcat( _NodePortName , "\\" ) ;
81 return _NodePortName ; } ;
83 const char * PortName() const {
86 return ServicesParameterName() ; } ;
87 const char * PortType() const { return ServicesParameterType() ; } ;
89 void Kind( SUPERV::KindOfPort aKindOfPort ) {
90 if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) {
91 cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort
94 _KindOfPort = aKindOfPort ; } ;
95 const SUPERV::KindOfPort Kind() const { return _KindOfPort ; } ;
96 bool IsParam() const {
97 return _KindOfPort == SUPERV::ServiceParameter ; } ;
99 return _KindOfPort == SUPERV::GateParameter ||
100 _KindOfPort == SUPERV::GOTOParameter ; } ;
101 bool IsInLine() const {
102 return _KindOfPort == SUPERV::InLineParameter ; } ;
103 bool IsLoop() const {
104 return _KindOfPort == SUPERV::LoopParameter ; } ;
105 bool IsSwitch() const {
106 return _KindOfPort == SUPERV::SwitchParameter ; } ;
107 bool IsEndSwitch() const {
108 return _KindOfPort == SUPERV::EndSwitchParameter ; } ;
109 bool IsGOTO() const {
110 return _KindOfPort == SUPERV::GOTOParameter ; } ;
111 // bool IsBus() const { return ( ( _KindOfPort == SUPERV::InLineParameter ) ||
112 // ( _PortIndex != -1 ) ) ; } ;
114 // void PortIndex( const int anIndex ) {
115 // _PortIndex = anIndex ; } ;
116 // const int PortIndex() const {
117 // return _PortIndex ; } ;
120 bool AddCoord( const int nxy , const int *x , const int *y ) ;
121 bool AddCoord( const int index , const int x , const int y ) ;
122 bool ChangeCoord( const int index ,
125 bool RemoveCoord( const int index ) ;
126 bool RemoveCoords() ;
127 int GetCoord() const ;
128 bool GetCoord( int *x , int *y ) const ;
129 const GraphBase::ListOfCoords * Coords() const ;
130 bool GetCoord( const int index , long &x , long &y ) const ;
136 ostream & operator<< (ostream &,const SUPERV::KindOfPort &);