Salome HOME
There was an error in the update of OutPort of Loop/EndLoopNodes (not used in the...
[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() {
52       };
53       OutPort( const char *const * NodeName  ,
54                const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
55                const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ,
56                const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) :
57                DataPort( NodeName , aserviceParameter , aKind , aDependency) {
58                _Connected = NotConnected ;
59                _InPortsSize = 0 ; } ;
60       virtual ~OutPort() {
61          cdebug << "GraphBase::OutPort::~OutPort " << PortName() << endl ; } ;
62       virtual void destroy() {
63          int i ;
64          for ( i = 0 ; i < _InPortsSize ; i++ ) {
65            _MapOfInPorts.erase( _InPorts[ i ]->PortName() ) ;
66 //           _InPorts[ i ]->destroy() ; BUG ...
67            _InPorts[ i ]->RemoveOutPort() ;
68          }
69          _InPorts.resize( 0 ) ;
70          cdebug << "GraphBase::OutPort::destroy " << PortName() << " "
71                 << NodeName() << endl ; } ;
72
73 // PortStatus has a meaning :
74 // It is NotConnected or PortConnected or DataConnected or ExternConnected
75 // Even if an OutPort may be connected to several ports the PortStatus is unique
76       const StatusOfPort PortStatus() const {
77             return _Connected; } ;
78       void PortStatus( StatusOfPort PortSts ) {
79 //           cdebug << "OutPort::PortStatus " << NodeName() << " " << PortName() << " "
80 //                  << _Connected << " --> " << PortSts << endl ;
81            _Connected = PortSts ; } ;
82       const bool IsNotConnected() const {
83             return ( _Connected == NotConnected ) ; } ;
84 //      const bool IsConnected() const {
85 //            return ( _Connected == PortConnected || _Connected == ExternConnected ) ; } ;
86       const bool IsPortConnected() const {
87             return ( _Connected == PortConnected ) ; } ;
88       const bool IsDataConnected() const {
89             return ( _Connected == DataConnected ) ; } ;
90       const bool IsExternConnected() const {
91             return ( _Connected == ExternConnected ) ; } ;
92 //      const bool IsPortAndDataConnected() const {
93 //            return ( _Connected == PortAndDataConnected ) ; } ;
94
95       const int InPortsSize() const {
96             return _InPortsSize ; } ;
97       const InPort * InPorts( const int i ) const {
98             return _InPorts[ i ] ; } ;
99       InPort * ChangeInPorts( const int i ) {
100             return _InPorts[ i ] ; } ;
101       SUPERV::Link_var LinkObjRef( const int i ) const {
102                         return _Links[ i ] ; } ;
103
104 //      bool RemoveLinks() ;
105
106       bool HasInPort() const ;
107       const InPort * GetInPort( const InPort * toPort ) ;
108       SUPERV::Link_var InPortObjRef( const InPort * toPort ) ;
109       bool AddInPort( InPort * toPort ) ;
110       bool AddInPortObjRef( InPort * toPort , SUPERV::Link_var aLink ) ;
111
112       bool RemoveInPort() ;
113       bool RemoveInPort( InPort * toPort ) ;
114       bool ReNameInPort( const char* OldNodePortName ,
115                          const char* NewNodePortName ) ;
116
117   } ;
118
119 } ;
120
121 ostream & operator<< (ostream &,const GraphBase::OutPort &);
122
123 #endif