Salome HOME
e425e486577eba1b0712fe4ed7bfe4f3e5112994
[modules/superv.git] / src / GraphBase / DataFlowBase_InPort.hxx
1 //=============================================================================
2 // File      : DataFlowBase_InPort.hxx
3 // Created   : 2002
4 // Author    : Jean Rahuel, CEA
5 // Project   : SALOME
6 // $Header:
7 //=============================================================================
8
9 #ifndef _DATAFLOWBASE_INPORT_HXX
10 #define _DATAFLOWBASE_INPORT_HXX
11
12 #include "DataFlowBase_Port.hxx"
13
14 namespace GraphBase {
15
16   class OutPort ;
17
18   class InPort : public Port {
19
20     SUPERV::GraphState   _State ;
21     OutPort *            _OutPort ;
22     OutPort *            _InitialOutPort ;
23
24     public:   
25
26       InPort() {
27            cout << "InPort()" << endl ;
28            _State = SUPERV::UndefinedState ;
29            _OutPort = NULL ;
30            _InitialOutPort = NULL ;
31       } ;
32       InPort( const char *const * NodeName  ,
33               const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
34               const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ) ;
35       virtual ~InPort() {
36          cdebug << "GraphBase::InPort::~InPort " << PortName() << endl ; } ;
37       virtual void destroy() {
38          _OutPort = NULL ;
39          _InitialOutPort = NULL ;
40          cdebug << "GraphBase::InPort::destroy " << PortName() << " "
41                 << NodeName() << endl ; } ;
42
43       void State( SUPERV::GraphState aState ) {
44            cdebug << pthread_self() << " " << PortName() << " from "
45                   << NodeName() << " SUPERV::GraphState " << _State << " "
46                   << " --> " << aState << " _EndSwitchPort "
47                   << IsEndSwitch() << endl ;
48            _State = aState ; } ;
49       SUPERV::GraphState State() { return _State ; } ;
50
51       OutPort * GetOutPort() {
52            return _OutPort ; } ;
53       OutPort * GetOutPort() const {
54            return _OutPort ; } ;
55       bool IsConnected() const ;
56       bool IsDataConnected() const ;
57       bool AddOutPort( OutPort * anOutPort ) {
58            if ( _OutPort )
59              return false ;
60            _OutPort = anOutPort ;
61            return true ; } ;
62       bool ChangeOutPort( OutPort * anOutPort ) {
63            if ( _InitialOutPort == NULL ) {
64              _InitialOutPort = _OutPort ;
65            }
66            _OutPort = anOutPort ;
67            return true ; } ;
68       bool InitialOutPort() {
69            if ( _InitialOutPort ) {
70              _OutPort = _InitialOutPort ;
71              _InitialOutPort = NULL ;
72              return true ;
73            }
74            return false ; } ;
75       bool RemoveOutPort() {
76            if ( _OutPort == NULL )
77              return false ;
78            _OutPort = NULL ;
79            return RemoveCoords() ; } ;
80
81       void StringValue(ostream & f ) const ;
82
83   } ;
84
85 } ;
86
87 ostream & operator<< (ostream &,const GraphBase::InPort &);
88
89 #endif