src/GraphBase/DataFlowBase_Base.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_Base.hxx
00025 //  Author : Jean Rahuel, CEA
00026 //  Module : SUPERV
00027 
00028 #ifndef _DATAFLOW_BASE_HXX
00029 #define _DATAFLOW_BASE_HXX
00030 
00031 //#include <strstream>
00032 #include <iostream>
00033 #include <fstream>
00034 #include <sstream>
00035 #include <iomanip>
00036 #include <string>
00037 #include <map>
00038 #include <vector>
00039 #include <list>
00040 
00041 #include <qdom.h>
00042 
00043 #include "CORBA.h"
00044 
00045 #include <SALOMEconfig.h>
00046 #include CORBA_CLIENT_HEADER(SUPERV)
00047 
00048 #include "utilities.h"
00049 #include "OpUtil.hxx"
00050 
00051 #define ExitWhenNodeAborted 1
00052 
00053 extern char *SuperVision_Version ;
00054 
00055 extern char *NULLSTRING ;
00056 
00057 extern char *FACTORYSERVER ;
00058 
00059 inline char * my_strdup( const char * s ) {
00060   if (s == NULL) return NULL;
00061 
00062   size_t l = strlen(s) + 1;
00063   char * t = new char[l];
00064   strcpy(t, s);
00065   return t;
00066 }
00067 
00068 inline char * my_strblkdup( const char * s ) {
00069   if (s == NULL) return NULL ;
00070 
00071   size_t l = strlen(s) + 1 ;
00072   int i ;
00073   for ( i = l - 2 ; i >= 0 ; i-- ) {
00074     if ( s[i] != ' ' ) {
00075       break ;
00076     }
00077     l = l - 1 ;
00078   }
00079   char * t = new char[l] ;
00080   strncpy(t, s , l-1) ;
00081   t[l-1] = '\0' ;
00082   return t;
00083 }
00084 
00085 string DataStreamTypeToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ;
00086 SALOME_ModuleCatalog::DataStreamType StringToDataStreamType( const char * aIdlType ) ;
00087 
00088 string KindOfDataStreamTraceToString( SUPERV::KindOfDataStreamTrace aDataStreamTrace ) ;
00089 
00090 string DataStreamDependencyToString( const SALOME_ModuleCatalog::DataStreamDependency aDataStreamDependency ) ;
00091 
00092 string DataStreamToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ;
00093 
00094 //enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected ,
00095 enum StatusOfPort { NotConnected , PortConnected ,
00096                     DataConnected , ExternConnected } ;
00097 
00098 namespace GraphBase {
00099 
00100   struct SCoord {
00101     long theX ;
00102     long theY ;
00103   };
00104     
00105   typedef vector<SCoord> ListOfCoords;
00106 
00107   typedef string FuncName ;
00108 
00109   typedef vector< FuncName > ListOfFuncName ;
00110 
00111   typedef vector<const SUPERV::ListOfStrings *> ListOfPythonFunctions ;
00112 
00113   typedef vector<SALOME_ModuleCatalog::ServicesParameter> ListOfParameters;
00114 
00115   struct InDataStreamParameter {
00116      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
00117      SUPERV::KindOfSchema                              theKindOfSchema ;
00118      SUPERV::KindOfInterpolation                       theKindOfInterpolation ;
00119      SUPERV::KindOfExtrapolation                       theKindOfExtrapolation ;
00120    };
00121   typedef vector<InDataStreamParameter> ListOfInDataStreamParameters;
00122 
00123   struct OutDataStreamParameter {
00124      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
00125      long                                              theNumberOfValues ;
00126    };
00127   typedef vector<OutDataStreamParameter> ListOfOutDataStreamParameters;
00128 
00129   struct SNode {
00130     string                        theComponentName ;
00131     string                        theInterfaceName ;
00132     string                        theName ;
00133     SUPERV::KindOfNode            theKind ;
00134     long                          theTimeout ;
00135     SUPERV::KindOfDataStreamTrace theDataStreamTrace ;
00136     double                        theDeltaTime ;
00137     string                        theCoupledNode ;
00138 //    int                           theDataStreamInArgsNumber ;
00139 //    int                           theDataStreamOutArgsNumber ;
00140     SALOME_ModuleCatalog::Service theService ;
00141     ListOfInDataStreamParameters  theListOfInDataStreams ;
00142     ListOfOutDataStreamParameters theListOfOutDataStreams ;
00143     ListOfFuncName                theListOfFuncName ;
00144     ListOfPythonFunctions         theListOfPythonFunctions ;
00145     SUPERV::SDate                 theFirstCreation ;
00146     SUPERV::SDate                 theLastModification ;
00147     string                        theEditorRelease ;
00148     string                        theAuthor ;
00149     string                        theContainer;
00150     string                        theComment;
00151     SCoord                        theCoords ;
00152   };
00153 
00154   typedef vector<SNode> ListOfSNodes;
00155 
00156   struct ServicesData {
00157     SALOME_ModuleCatalog::ServicesParameter aDataParameter ;
00158     CORBA::Any                              aDataValue;
00159   };
00160 
00161   typedef vector<ServicesData> ListOfServicesData;
00162 
00163   struct SLink {
00164     string       FromNodeName ;
00165     string       FromServiceParameterName ;
00166     string       ToNodeName ;
00167     string       ToServiceParameterName ;
00168     CORBA::Any   aLinkValue;
00169     ListOfCoords aListOfCoords ;
00170   };
00171 
00172   typedef vector<SLink> ListOfSLinks;
00173 
00174   struct SGraph {
00175     SNode        Info ;
00176     ListOfSNodes  Nodes ;
00177     ListOfSLinks  Links ;
00178     ListOfSLinks  Datas ;
00179   };
00180 
00181   typedef vector<SGraph> ListOfSGraphs;
00182 
00183   class Base {
00184 
00185     private:   
00186 
00187       CORBA::ORB_ptr _Orb ;
00188 
00189     public:   
00190 
00191       int      * _prof_debug ;
00192       ofstream * _fdebug ;
00193                      
00194       Base() ;
00195       virtual ~Base() {} ;
00196 
00197       void SetDebug( CORBA::ORB_ptr ORB ,
00198                      int * prof_debug , ofstream * fdebug ) ;
00199 
00200       char * ObjectToString( CORBA::Object_ptr obj ) const ;
00201       CORBA::Object_ptr StringToObject(char * obj ) const ;
00202 
00203       ostream & AnyValue( const CORBA::Any & anAny );
00204 
00205   } ;
00206 
00207 # ifdef _DEBUG_
00208 
00209 #   define cdebug if ( GraphBase::Base::_fdebug )  *GraphBase::Base::_fdebug << "      "
00210 #   define cdebug_in if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "-->" << " "
00211 #   define cdebug_out if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "<--" << " "
00212 
00213 # else
00214 
00215 #   define cdebug while (false) std::cerr
00216 #   define cdebug_in  cdebug
00217 #   define cdebug_out cdebug
00218 #   define debugFile(x) 
00219 
00220 #endif
00221 
00222 } ;
00223 
00224 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamType &);
00225 
00226 #endif