src/GraphBase/DataFlowBase_OutPort.hxx

Go to the documentation of this file.
00001 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
00002 //
00003 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
00005 // 
00006 //  This library is free software; you can redistribute it and/or 
00007 //  modify it under the terms of the GNU Lesser General Public 
00008 //  License as published by the Free Software Foundation; either 
00009 //  version 2.1 of the License. 
00010 // 
00011 //  This library is distributed in the hope that it will be useful, 
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00014 //  Lesser General Public License for more details. 
00015 // 
00016 //  You should have received a copy of the GNU Lesser General Public 
00017 //  License along with this library; if not, write to the Free Software 
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
00019 // 
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //
00023 //
00024 //  File   : DataFlowBase_OutPort.hxx
00025 //  Author : Jean Rahuel, CEA
00026 //  Module : SUPERV
00027 //  $Header:
00028 
00029 #ifndef _DATAFLOWBASE_OUTPORT_HXX
00030 #define _DATAFLOWBASE_OUTPORT_HXX
00031 
00032 #include "DataFlowBase_DataPort.hxx"
00033 #include "DataFlowBase_InPort.hxx"
00034 
00035 namespace GraphBase {
00036 
00037   class OutPort : public DataPort {
00038 
00039     private:
00040 
00041       StatusOfPort _Connected ;
00042 
00043 // Inports connected to this OutPort
00044       map< string , int >        _MapOfInPorts ;
00045       int                        _InPortsSize ;
00046       vector<InPort * >          _InPorts ;
00047       vector<SUPERV::Link_var >  _Links ;
00048 
00049     public:   
00050 
00051       OutPort() {
00052       };
00053       OutPort( const char *const * NodeName  ,
00054                const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
00055                const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ,
00056                const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) :
00057                DataPort( NodeName , aserviceParameter , aKind , aDependency) {
00058                _Connected = NotConnected ;
00059                _InPortsSize = 0 ; } ;
00060       virtual ~OutPort() {
00061          cdebug << "GraphBase::OutPort::~OutPort " << PortName() << endl ; } ;
00062       virtual void destroy() {
00063          int i ;
00064          for ( i = 0 ; i < _InPortsSize ; i++ ) {
00065            _MapOfInPorts.erase( _InPorts[ i ]->PortName() ) ;
00066 //           _InPorts[ i ]->destroy() ; BUG ...
00067            _InPorts[ i ]->RemoveOutPort() ;
00068       }
00069          _InPorts.resize( 0 ) ;
00070          cdebug << "GraphBase::OutPort::destroy " << PortName() << " "
00071                 << NodeName() << endl ; } ;
00072 
00073 // PortStatus has a meaning :
00074 // It is NotConnected or PortConnected or DataConnected or ExternConnected
00075 // Even if an OutPort may be connected to several ports the PortStatus is unique
00076       const StatusOfPort PortStatus() const {
00077             return _Connected; } ;
00078       void PortStatus( StatusOfPort PortSts ) {
00079 //           cdebug << "OutPort::PortStatus " << NodeName() << " " << PortName() << " "
00080 //                  << _Connected << " --> " << PortSts << endl ;
00081            _Connected = PortSts ; } ;
00082       const bool IsNotConnected() const {
00083             return ( _Connected == NotConnected ) ; } ;
00084 //      const bool IsConnected() const {
00085 //            return ( _Connected == PortConnected || _Connected == ExternConnected ) ; } ;
00086       const bool IsPortConnected() const {
00087             return ( _Connected == PortConnected ) ; } ;
00088       const bool IsDataConnected() const {
00089             return ( _Connected == DataConnected ) ; } ;
00090       const bool IsExternConnected() const {
00091             return ( _Connected == ExternConnected ) ; } ;
00092 //      const bool IsPortAndDataConnected() const {
00093 //            return ( _Connected == PortAndDataConnected ) ; } ;
00094 
00095       const int InPortsSize() const {
00096             return _InPortsSize ; } ;
00097       const InPort * InPorts( const int i ) const {
00098             return _InPorts[ i ] ; } ;
00099       InPort * ChangeInPorts( const int i ) {
00100             return _InPorts[ i ] ; } ;
00101       SUPERV::Link_var LinkObjRef( const int i ) const {
00102                         return _Links[ i ] ; } ;
00103 
00104 //      bool RemoveLinks() ;
00105 
00106       bool HasInPort() const ;
00107       const InPort * GetInPort( const InPort * toPort ) ;
00108       SUPERV::Link_var InPortObjRef( const InPort * toPort ) ;
00109       bool AddInPort( InPort * toPort ) ;
00110       bool AddInPortObjRef( InPort * toPort , SUPERV::Link_var aLink ) ;
00111 
00112       bool RemoveInPort() ;
00113       bool RemoveInPort( InPort * toPort ) ;
00114       bool ReNameInPort( const char* OldNodePortName ,
00115                          const char* NewNodePortName ) ;
00116 
00117   } ;
00118 
00119 } ;
00120 
00121 ostream & operator<< (ostream &,const GraphBase::OutPort &);
00122 
00123 #endif