Salome HOME
c4464d8c4d9dff859fa19a05b885f109fdcde8d2
[modules/superv.git] / src / GraphBase / DataFlowBase_InPort.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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : DataFlowBase_InPort.hxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 #ifndef _DATAFLOWBASE_INPORT_HXX
30 #define _DATAFLOWBASE_INPORT_HXX
31
32 #include "DataFlowBase_Port.hxx"
33
34 namespace GraphBase {
35
36   class OutPort ;
37
38   class InPort : public Port {
39
40     private:
41
42       SUPERV::GraphState   _PortState ;
43       OutPort *            _OutPort ;
44       OutPort *            _InitialOutPort ;
45       bool                 _BranchOfSwitchLinked ; // For Check from Branches to EndOfSwitch links
46
47     public:   
48
49       InPort() ;
50       InPort( const char *const * NodeName  ,
51               const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
52               const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ,
53               const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) ;
54       virtual ~InPort() {
55          cdebug << "GraphBase::InPort::~InPort " << PortName() << endl ; } ;
56       virtual void destroy() {
57          _OutPort = NULL ;
58          _InitialOutPort = NULL ;
59          cdebug << "GraphBase::InPort::destroy " << PortName() << " "
60                 << NodeName() << endl ; } ;
61
62       void PortState( SUPERV::GraphState aPortState ) {
63 //           cdebug << pthread_self() << " " << PortName() << " from "
64 //                  << NodeName() << " SUPERV::GraphState " << _State << " "
65 //                  << " --> " << aPortState << " _EndSwitchPort "
66 //                  << IsEndSwitch() << endl ;
67            _PortState = aPortState ; } ;
68       SUPERV::GraphState PortState() { return _PortState ; } ;
69
70       OutPort * GetOutPort() {
71            return _OutPort ; } ;
72       OutPort * GetOutPort() const {
73            return _OutPort ; } ;
74       const StatusOfPort PortStatus() const ;
75
76       bool IsNotConnected() const ;
77 //      bool IsConnected() const ;
78       bool IsPortConnected() const ;
79       bool IsDataConnected() const ;
80       bool IsExternConnected() const ;
81
82       bool AddOutPort( OutPort * anOutPort ) {
83            if ( _OutPort )
84              return false ;
85            _OutPort = anOutPort ;
86            return true ; } ;
87       bool ChangeOutPort( OutPort * anOutPort ) ;
88       bool InitialOutPort() {
89            if ( _InitialOutPort ) {
90              _OutPort = _InitialOutPort ;
91              _InitialOutPort = NULL ;
92              return true ;
93            }
94            return false ; } ;
95       bool RemoveOutPort( bool DoRemoveInPort = true ) ;
96
97       bool BranchOfSwitchLinked( bool aInPortLinked ) {
98            if ( aInPortLinked && _BranchOfSwitchLinked ) {
99              return false ; // Already setted
100            }
101            _BranchOfSwitchLinked = aInPortLinked ;
102            return true ; } ;
103       bool BranchOfSwitchLinked() {
104            return _BranchOfSwitchLinked ; } ;
105
106       void StringValue(ostream & f ) const ;
107
108   } ;
109
110 } ;
111
112 ostream & operator<< (ostream &,const GraphBase::InPort &);
113
114 ostream & operator<< (ostream &,const SUPERV::GraphState &);
115
116 #endif