]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_Base.hxx
Salome HOME
4dd042eef4ed65747d9b2ecb5b71fbd4a6388b7c
[modules/superv.git] / src / GraphBase / DataFlowBase_Base.hxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : DataFlowBase_Base.hxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27
28 #ifndef _DATAFLOW_BASE_HXX
29 #define _DATAFLOW_BASE_HXX
30
31 //#include <strstream>
32 #include <iostream>
33 #include <fstream>
34 #include <sstream>
35 #include <iomanip>
36 #include <string>
37 #include <map>
38 #include <vector>
39 #include <list>
40
41 #include <qdom.h>
42
43 #include "CORBA.h"
44
45 #include <SALOMEconfig.h>
46 #include CORBA_CLIENT_HEADER(SUPERV)
47
48 #include "utilities.h"
49 #include "OpUtil.hxx"
50
51 #define ExitWhenNodeAborted 1
52
53 extern char *SuperVision_Version ;
54
55 extern char *NULLSTRING ;
56
57 extern char *FACTORYSERVER ;
58
59 inline char * my_strdup( const char * s ) {
60   if (s == NULL) return NULL;
61
62   size_t l = strlen(s) + 1;
63   char * t = new char[l];
64   strcpy(t, s);
65   return t;
66 }
67
68 inline char * my_strblkdup( const char * s ) {
69   if (s == NULL) return NULL ;
70
71   size_t l = strlen(s) + 1 ;
72   int i ;
73   for ( i = l - 2 ; i >= 0 ; i-- ) {
74     if ( s[i] != ' ' ) {
75       break ;
76     }
77     l = l - 1 ;
78   }
79   char * t = new char[l] ;
80   strncpy(t, s , l-1) ;
81   t[l-1] = '\0' ;
82   return t;
83 }
84
85 string DataStreamTypeToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ;
86 SALOME_ModuleCatalog::DataStreamType StringToDataStreamType( const char * aIdlType ) ;
87
88 string KindOfDataStreamTraceToString( SUPERV::KindOfDataStreamTrace aDataStreamTrace ) ;
89
90 string DataStreamDependencyToString( const SALOME_ModuleCatalog::DataStreamDependency aDataStreamDependency ) ;
91
92 string DataStreamToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ;
93
94 //enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected ,
95 enum StatusOfPort { NotConnected , PortConnected ,
96                     DataConnected , ExternConnected } ;
97
98 namespace GraphBase {
99
100   struct SCoord {
101     long theX ;
102     long theY ;
103   };
104     
105   typedef vector<SCoord> ListOfCoords;
106
107   typedef string FuncName ;
108
109   typedef vector< FuncName > ListOfFuncName ;
110
111   typedef vector<const SUPERV::ListOfStrings *> ListOfPythonFunctions ;
112
113   typedef vector<SALOME_ModuleCatalog::ServicesParameter> ListOfParameters;
114
115   struct InDataStreamParameter {
116      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
117      SUPERV::KindOfSchema                              theKindOfSchema ;
118      SUPERV::KindOfInterpolation                       theKindOfInterpolation ;
119      SUPERV::KindOfExtrapolation                       theKindOfExtrapolation ;
120    };
121   typedef vector<InDataStreamParameter> ListOfInDataStreamParameters;
122
123   struct OutDataStreamParameter {
124      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
125      long                                              theNumberOfValues ;
126    };
127   typedef vector<OutDataStreamParameter> ListOfOutDataStreamParameters;
128
129   struct SNode {
130     string                        theComponentName ;
131     string                        theInterfaceName ;
132     string                        theName ;
133     SUPERV::KindOfNode            theKind ;
134     long                          theTimeout ;
135     SUPERV::KindOfDataStreamTrace theDataStreamTrace ;
136     double                        theDeltaTime ;
137     string                        theCoupledNode ;
138 //    int                           theDataStreamInArgsNumber ;
139 //    int                           theDataStreamOutArgsNumber ;
140     SALOME_ModuleCatalog::Service theService ;
141     ListOfInDataStreamParameters  theListOfInDataStreams ;
142     ListOfOutDataStreamParameters theListOfOutDataStreams ;
143     ListOfFuncName                theListOfFuncName ;
144     ListOfPythonFunctions         theListOfPythonFunctions ;
145     SUPERV::SDate                 theFirstCreation ;
146     SUPERV::SDate                 theLastModification ;
147     string                        theEditorRelease ;
148     string                        theAuthor ;
149     string                        theContainer;
150     string                        theComment;
151     SCoord                        theCoords ;
152   };
153
154   typedef vector<SNode> ListOfSNodes;
155
156   struct ServicesData {
157     SALOME_ModuleCatalog::ServicesParameter aDataParameter ;
158     CORBA::Any                              aDataValue;
159   };
160
161   typedef vector<ServicesData> ListOfServicesData;
162
163   struct SLink {
164     string       FromNodeName ;
165     string       FromServiceParameterName ;
166     string       ToNodeName ;
167     string       ToServiceParameterName ;
168     CORBA::Any   aLinkValue;
169     ListOfCoords aListOfCoords ;
170   };
171
172   typedef vector<SLink> ListOfSLinks;
173
174   struct SGraph {
175     SNode        Info ;
176     ListOfSNodes  Nodes ;
177     ListOfSLinks  Links ;
178     ListOfSLinks  Datas ;
179   };
180
181   typedef vector<SGraph> ListOfSGraphs;
182
183   class Base {
184
185     private:   
186
187       CORBA::ORB_ptr _Orb ;
188
189     public:   
190
191       int      * _prof_debug ;
192       ofstream * _fdebug ;
193                      
194       Base() ;
195       virtual ~Base() {} ;
196
197       void SetDebug( CORBA::ORB_ptr ORB ,
198                      int * prof_debug , ofstream * fdebug ) ;
199
200       char * ObjectToString( CORBA::Object_ptr obj ) const ;
201       CORBA::Object_ptr StringToObject(char * obj ) const ;
202
203       ostream & AnyValue( const CORBA::Any & anAny );
204
205   } ;
206
207 # ifdef _DEBUG_
208
209 #   define cdebug if ( GraphBase::Base::_fdebug )  *GraphBase::Base::_fdebug << "      "
210 #   define cdebug_in if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "-->" << " "
211 #   define cdebug_out if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "<--" << " "
212
213 # else
214
215 #   define cdebug while (false) std::cerr
216 #   define cdebug_in  cdebug
217 #   define cdebug_out cdebug
218 #   define debugFile(x) 
219
220 #endif
221
222 } ;
223
224 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamType &);
225
226 #endif