Salome HOME
6aa2f797fcdd1ee5d90abf68010dbed87b74fc21
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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     SUPERV::GraphState   _State ;
41     OutPort *            _OutPort ;
42     OutPort *            _InitialOutPort ;
43
44     public:   
45
46       InPort() {
47 //           cout << "InPort()" << endl ;
48            _State = SUPERV::UndefinedState ;
49            _OutPort = NULL ;
50            _InitialOutPort = NULL ;
51       } ;
52       InPort( const char *const * NodeName  ,
53               const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
54               const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ) ;
55       virtual ~InPort() {
56          cdebug << "GraphBase::InPort::~InPort " << PortName() << endl ; } ;
57       virtual void destroy() {
58          _OutPort = NULL ;
59          _InitialOutPort = NULL ;
60          cdebug << "GraphBase::InPort::destroy " << PortName() << " "
61                 << NodeName() << endl ; } ;
62
63       void State( SUPERV::GraphState aState ) {
64 //           cdebug << pthread_self() << " " << PortName() << " from "
65 //                  << NodeName() << " SUPERV::GraphState " << _State << " "
66 //                  << " --> " << aState << " _EndSwitchPort "
67 //                  << IsEndSwitch() << endl ;
68            _State = aState ; } ;
69       SUPERV::GraphState State() { return _State ; } ;
70
71       OutPort * GetOutPort() {
72            return _OutPort ; } ;
73       OutPort * GetOutPort() const {
74            return _OutPort ; } ;
75       bool IsConnected() const ;
76       bool IsDataConnected() const ;
77       bool AddOutPort( OutPort * anOutPort ) {
78            if ( _OutPort )
79              return false ;
80            _OutPort = anOutPort ;
81            return true ; } ;
82       bool ChangeOutPort( OutPort * anOutPort ) {
83            if ( _InitialOutPort == NULL ) {
84              _InitialOutPort = _OutPort ;
85            }
86            _OutPort = anOutPort ;
87            return true ; } ;
88       bool InitialOutPort() {
89            if ( _InitialOutPort ) {
90              _OutPort = _InitialOutPort ;
91              _InitialOutPort = NULL ;
92              return true ;
93            }
94            return false ; } ;
95       bool RemoveOutPort() {
96            if ( _OutPort == NULL )
97              return false ;
98            _OutPort = NULL ;
99            return RemoveCoords() ; } ;
100
101       void StringValue(ostream & f ) const ;
102
103   } ;
104
105 } ;
106
107 ostream & operator<< (ostream &,const GraphBase::InPort &);
108
109 #endif