Salome HOME
sources v1.2
[modules/superv.git] / src / GraphBase / DataFlowBase_OutPort.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_OutPort.hxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 #ifndef _DATAFLOWBASE_OUTPORT_HXX
30 #define _DATAFLOWBASE_OUTPORT_HXX
31
32 #include "DataFlowBase_DataPort.hxx"
33 #include "DataFlowBase_InPort.hxx"
34
35 namespace GraphBase {
36
37   class OutPort : public DataPort {
38
39     private:
40
41       StatusOfPort _Connected ;
42
43 // Inports connected to this OutPort
44       map< string , int >        _MapOfInPorts ;
45       int                        _InPortsSize ;
46       vector<InPort * >          _InPorts ;
47       vector<SUPERV::Link_var >  _Links ;
48
49     public:   
50
51       OutPort( const char *const * NodeName  ,
52                const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
53                const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ) :
54                DataPort( NodeName , aserviceParameter ) {
55                _Connected = NotConnected ;
56                _InPortsSize = 0 ;
57                Kind( aKind ) ; } ;
58       virtual ~OutPort() {
59          cdebug << "GraphBase::OutPort::~OutPort " << PortName() << endl ; } ;
60       virtual void destroy() {
61          int i ;
62          for ( i = 0 ; i < _InPortsSize ; i++ ) {
63            _MapOfInPorts.erase( _InPorts[ i ]->PortName() ) ;
64 //           _InPorts[ i ]->destroy() ; BUG ...
65            _InPorts[ i ]->RemoveOutPort() ;
66          }
67          _InPorts.resize( 0 ) ;
68          cdebug << "GraphBase::OutPort::destroy " << PortName() << " "
69                 << NodeName() << endl ; } ;
70
71       const StatusOfPort PortStatus() const {
72             return _Connected; } ;
73       void PortStatus(StatusOfPort c) { _Connected = c; } ;
74       const bool IsNotConnected() const {
75             return ( _Connected == NotConnected ) ; } ;
76       const bool IsConnected() const {
77             return ( _Connected != NotConnected ) ; } ;
78       const bool IsPortConnected() const {
79             return ( _Connected == PortConnected ||
80                      _Connected == PortAndDataConnected ) ; } ;
81       const bool IsPortAndDataConnected() const {
82             return ( _Connected == PortAndDataConnected ) ; } ;
83       const bool IsDataConnected() const {
84             return ( _Connected == DataConnected ) ; } ;
85
86       const int InPortsSize() const {
87             return _InPortsSize ; } ;
88       const InPort * InPorts( const int i ) const {
89             return _InPorts[ i ] ; } ;
90       InPort * ChangeInPorts( const int i ) {
91             return _InPorts[ i ] ; } ;
92       SUPERV::Link_var LinkObjRef( const int i ) const {
93                         return _Links[ i ] ; } ;
94
95 //      bool RemoveLinks() ;
96
97       bool HasInPort() const ;
98       const InPort * GetInPort( const InPort * toPort ) ;
99       SUPERV::Link_var InPortObjRef( const InPort * toPort ) ;
100       bool AddInPort( InPort * toPort ) ;
101       bool AddInPortObjRef( InPort * toPort , SUPERV::Link_var aLink ) ;
102
103       bool RemoveInPort( InPort * toPort ) ;
104       bool ReNameInPort( const char* OldNodePortName ,
105                          const char* NewNodePortName ) ;
106
107   } ;
108
109 } ;
110
111 ostream & operator<< (ostream &,const GraphBase::OutPort &);
112
113 #endif