Salome HOME
ddee288874e49c16567ab990e82a0d6fe387e15a
[modules/superv.git] / src / GraphBase / DataFlowBase_Port.hxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_Port.hxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 #ifndef _DATAFLOWBASE_PORT_HXX
30 #define _DATAFLOWBASE_PORT_HXX
31
32 #include <list>
33 #include <vector>
34
35 #include "DataFlowBase_ServicesParameter.hxx"
36
37 namespace GraphBase {
38
39   class Port : public ServicesParameter {
40
41     const char *const * _NodeName ;
42     SUPERV::Port_var    _Port ;
43     SUPERV::KindOfPort  _KindOfPort ;
44
45     vector<long > _X ;    
46     vector<long > _Y ;    
47
48     public:   
49
50     Port() {
51 //         cout << "Port()" << endl ;
52          _NodeName = NULL ;
53          _Port = SUPERV::Port::_nil() ;
54          _KindOfPort = SUPERV::UndefinedParameter ;
55     } ;
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 ;
63         } ;
64     virtual ~Port() {
65          cdebug << "~Port" << endl ; } ;
66
67     SUPERV::Port_var ObjRef() const { return _Port ; } ;
68     void ObjRef(SUPERV::Port_var aPort) {
69                 _Port = aPort ; } ;
70
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 ; } ;          
82
83     const char * PortName() const {
84           if ( this == NULL )
85             return NULLSTRING ;
86           return ServicesParameterName() ; } ;
87     const char * PortType() const { return ServicesParameterType() ; } ;
88
89     void Kind( SUPERV::KindOfPort aKindOfPort ) {
90          if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) {
91            cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort
92                   << endl ;
93          }
94          _KindOfPort = aKindOfPort ; } ;
95     const SUPERV::KindOfPort Kind() const { return _KindOfPort ; } ;
96     bool IsParam() const {
97          return _KindOfPort == SUPERV::ServiceParameter ; } ;
98     bool IsGate() const {
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 ) ) ; } ;
113
114 //    void PortIndex( const int anIndex ) {
115 //         _PortIndex = anIndex ; } ;
116 //    const int PortIndex() const {
117 //          return _PortIndex ; } ;
118
119
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 ,
123                       const int x ,
124                       const int y ) ;
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 ;
131
132   } ;
133
134 } ;
135
136 ostream & operator<< (ostream &,const SUPERV::KindOfPort &);
137
138 #endif