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