src/GraphBase/DataFlowBase_Port.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_Port.hxx
00025 //  Author : Jean Rahuel, CEA
00026 //  Module : SUPERV
00027 //  $Header:
00028 
00029 #ifndef _DATAFLOWBASE_PORT_HXX
00030 #define _DATAFLOWBASE_PORT_HXX
00031 
00032 #include <list>
00033 #include <vector>
00034 
00035 #include "DataFlowBase_ServicesParameter.hxx"
00036 
00037 namespace GraphBase {
00038 
00039   class Port : public ServicesParameter {
00040 
00041     private:
00042 
00043       const char *const * _NodeName ;
00044       SUPERV::Port_var    _Port ;
00045       SUPERV::KindOfPort  _KindOfPort ;
00046 
00047       vector<long > _X ;    
00048       vector<long > _Y ;    
00049 
00050       SALOME_ModuleCatalog::DataStreamDependency _Dependency ; // Time or Iteration only for DataStreamPorts
00051 
00052     public:   
00053 
00054       Port() {
00055            _NodeName = NULL ;
00056            _Port = SUPERV::Port::_nil() ;
00057            _KindOfPort = SUPERV::UndefinedParameter ;
00058            _Dependency  = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ; } ;
00059       Port( const char *const * NodeName ,
00060             const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ,
00061             const SUPERV::KindOfPort aKindOfPort = SUPERV::ServiceParameter ,
00062             const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) :
00063             ServicesParameter( aserviceParameter ) {
00064             _NodeName = NodeName ;
00065 //            cdebug << "Port::Port _NodeName " << _NodeName << " = " << (void * ) *_NodeName
00066 //                   << " = " << _NodeName << " in Port " << PortName() << endl ;
00067             _Port = SUPERV::Port::_nil() ;
00068             _KindOfPort = aKindOfPort ;
00069             if ( IsDataStream() ) {
00070               _Dependency = aDependency ;
00071          }
00072             else {
00073               _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ;
00074          } } ;
00075       virtual ~Port() {
00076          cdebug << "~Port _NodeName " << *_NodeName << endl ; } ;
00077 
00078       SUPERV::Port_var ObjRef() const { return _Port ; } ;
00079       void ObjRef(SUPERV::Port_var aPort) {
00080                   _Port = aPort ; } ;
00081 
00082       const char * NodeName() const {
00083 //            cdebug << "Port::NodeName _NodeName " << _NodeName << " = " << (void * ) *_NodeName
00084 //                   << " = " << *_NodeName << " in Port " << PortName() << endl ;
00085             return *_NodeName ; } ;
00086       const char * NodePortName() const {
00087 //            cout << "NodePortName " << hex << (void *) _NodeName << " "
00088 //                 << dec << _NodeName << endl ;
00089             char * _NodePortName = new char [ strlen( *_NodeName ) +
00090                                    strlen( ServicesParameterName() ) + 4 ] ;
00091             strcpy( _NodePortName , *_NodeName ) ;
00092 //            strcat( _NodePortName , "\\" ) ;
00093             strcat( _NodePortName , "__" ) ;
00094             strcat( _NodePortName , ServicesParameterName() ) ;
00095             return _NodePortName ; } ;          
00096 
00097       const char * PortName() const {
00098             if ( this == NULL )
00099               return NULLSTRING ;
00100             return ServicesParameterName() ; } ;
00101       const char * PortType() const { return ServicesParameterType() ; } ;
00102 
00103       void PortType(char * aParametertype ) { ServicesParameterType( aParametertype ) ; } ;
00104       void Kind( SUPERV::KindOfPort aKindOfPort ) {
00105            if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) {
00106              cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort
00107                     << endl ;
00108         }
00109            _KindOfPort = aKindOfPort ; } ;
00110       const SUPERV::KindOfPort Kind() const {
00111             return _KindOfPort ; } ;
00112       bool IsParam() const {
00113            return _KindOfPort == SUPERV::ServiceParameter ; } ;
00114       bool IsGate() const {
00115            return _KindOfPort == SUPERV::GateParameter ||
00116                   _KindOfPort == SUPERV::GOTOParameter ; } ;
00117       bool IsInLine() const {
00118            return _KindOfPort == SUPERV::InLineParameter ; } ;
00119       bool IsLoop() const {
00120            return _KindOfPort == SUPERV::LoopParameter ; } ;
00121       bool IsSwitch() const {
00122            return _KindOfPort == SUPERV::SwitchParameter ; } ;
00123       bool IsEndSwitch() const {
00124            return _KindOfPort == SUPERV::EndSwitchParameter ; } ;
00125       bool IsGOTO() const {
00126            return _KindOfPort == SUPERV::GOTOParameter ; } ;
00127       bool IsDataStream() const {
00128            return _KindOfPort == SUPERV::DataStreamParameter ; } ;
00129 
00130       const SALOME_ModuleCatalog::DataStreamDependency Dependency() const {
00131                                      return _Dependency ; } ;
00132       bool Dependency( SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
00133            if ( IsDataStream() ) {
00134              _Dependency = aDependency ;
00135              return true ;
00136         }
00137            return false ; } ;
00138 
00139       bool AddCoord( const int nxy , const int *x , const int *y ) ;
00140       bool AddCoord( const int index , const int x , const int y ) ;
00141       bool ChangeCoord( const int index ,
00142                         const int x ,
00143                         const int y ) ;
00144       bool RemoveCoord( const int index ) ;
00145       bool RemoveCoords() ;
00146       int GetCoord() const ;
00147       bool GetCoord( int *x , int *y ) const ;
00148       const GraphBase::ListOfCoords * Coords() const ;
00149       bool GetCoord( const int index , CORBA::Long &x , CORBA::Long &y ) const ;
00150 
00151   } ;
00152 
00153 } ;
00154 
00155 ostream & operator<< (ostream &,const SUPERV::KindOfPort &);
00156 
00157 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamDependency &);
00158 
00159 ostream & operator<< (ostream &,const StatusOfPort &);
00160 
00161 #endif