2 //=============================================================================
3 // File : DataFlowBase_OutPort.cxx
5 // Author : Jean Rahuel, CEA
8 //=============================================================================
10 #include "DataFlowBase_OutPort.hxx"
12 //GraphBase::OutPort::~OutPort() {
13 // In GraphExecutor::OutPort
15 // for ( i = 1 ; i <= _InPortsSize ; i++ ) {
16 // if ( !_InPorts[ i ]->RemoveLink() )
17 // cout << "GraphBase::OutPort::~OutPort error "
18 // << _InPorts[ i ]->PortName() << endl ;
22 bool GraphBase::OutPort::HasInPort() const {
23 return _InPortsSize != 0 ;
26 const GraphBase::InPort * GraphBase::OutPort::GetInPort(
27 const GraphBase::InPort * toPort ) {
28 const GraphBase::InPort * anInPort = NULL ;
29 int index = _MapOfInPorts[ toPort->NodePortName() ] ;
30 if ( index > 0 && index <= _InPortsSize ) {
31 anInPort = _InPorts[ index-1 ] ;
32 if ( anInPort != toPort ) {
33 cout << "GraphBase::OutPort::GetInPort inconsistency toPort "
34 << hex << (void *) toPort << " != anInPort " << (void *) anInPort
42 SUPERV::Link_var GraphBase::OutPort::InPortObjRef(
43 const GraphBase::InPort * toPort ) {
44 SUPERV::Link_var aLink = SUPERV::Link::_nil() ;
45 int index = _MapOfInPorts[ toPort->NodePortName() ] ;
46 if ( index > 0 && index <= _InPortsSize ) {
47 aLink = _Links[ index-1 ] ;
52 bool GraphBase::OutPort::AddInPort( GraphBase::InPort * toPort ) {
53 int index = _MapOfInPorts[ toPort->NodePortName() ] ;
54 if ( index > 0 && index <= _InPortsSize ) {
58 _InPorts.resize( _InPortsSize ) ;
59 _MapOfInPorts[ toPort->NodePortName() ] = _InPortsSize ;
60 _InPorts[ _InPortsSize-1 ] = toPort ;
61 _Links.resize( _InPortsSize ) ;
62 _Links[ _InPortsSize-1 ] = SUPERV::Link::_nil() ;
63 cdebug << "OutPort " << NodeName() << "(" << PortName() << ") --> InPort "
64 << toPort->NodeName() << "(" << toPort->PortName() << ") SwitchPort "
65 << toPort->IsEndSwitch() << endl ;
69 bool GraphBase::OutPort::AddInPortObjRef( GraphBase::InPort * toPort ,
70 SUPERV::Link_var aLink ) {
71 int index = _MapOfInPorts[ toPort->NodePortName() ] ;
72 if ( index <= 0 || index > _InPortsSize ) {
75 _Links[ index - 1 ] = aLink ;
79 bool GraphBase::OutPort::RemoveInPort( GraphBase::InPort * toPort ) {
81 int index = _MapOfInPorts[ toPort->NodePortName() ] ;
82 if ( index <= 0 || index > _InPortsSize ) {
83 cdebug << "GraphBase::OutPort::RemoveInPort Error " << NodePortName()
84 << " --> " << toPort->NodePortName() << endl ;
88 for ( i = index - 1 ; i < _InPortsSize ; i++ ) {
89 _MapOfInPorts[ _InPorts[ i+1 ]->NodePortName() ] = i + 1 ;
90 _InPorts[ i ] = _InPorts[ i+1 ] ;
91 _Links[ i ] = _Links[ i+1 ] ;
93 _InPorts.resize( _InPortsSize ) ;
94 _Links.resize( _InPortsSize ) ;
95 _MapOfInPorts.erase( toPort->NodePortName() ) ;
96 if ( _InPortsSize == 0 ) {
97 PortStatus(NotConnected ) ;
99 toPort->RemoveOutPort() ;
103 bool GraphBase::OutPort::ReNameInPort( const char* OldNodePortName ,
104 const char* NewNodePortName ) {
105 int index = _MapOfInPorts[ OldNodePortName ] ;
106 if ( index <= 0 || index > _InPortsSize ) {
107 cdebug << "GraphBase::OutPort::ReNameLink Error " << OldNodePortName
108 << " --> " << NewNodePortName << " index " << index << endl ;
111 _MapOfInPorts.erase( OldNodePortName ) ;
112 _MapOfInPorts[ NewNodePortName ] = index ;
117 bool GraphBase::OutPort::RemoveLinks() {
120 for ( i = 0 ; i < _InPortsSize ; i++ ) {
121 MESSAGE( " to " << *_InPorts[ i ] );
122 RetVal = _InPorts[ i ]->RemoveLink() ;
125 RetVal = RemoveLink( _InPorts[ i ] ) ;
129 PortStatus(NotConnected ) ;
134 ostream & operator<< (ostream &f ,const GraphBase::OutPort &P)
136 f << P.PortName() << ", "
137 << "type : " << P.PortType() << ", " ;
140 << P.NodeName() << ", ";