Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_Base.hxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 #ifndef _DATAFLOW_BASE_HXX
30 #define _DATAFLOW_BASE_HXX
31
32 //#include <strstream>
33 #include <iostream>
34 #include <fstream>
35 #include <sstream>
36 #include <iomanip>
37 #include <string>
38 #include <map>
39 #include <vector>
40 #include <list>
41
42 #include <qdom.h>
43
44 #include "CORBA.h"
45
46 #include <SALOMEconfig.h>
47 #include CORBA_CLIENT_HEADER(SUPERV)
48
49 #include "utilities.h"
50 #include "OpUtil.hxx"
51
52 extern char *SuperVision_Version ;
53
54 extern char *NULLSTRING ;
55
56 extern char *FACTORYSERVER ;
57
58 inline char * my_strdup( const char * s ) {
59   if (s == NULL) return NULL;
60
61   size_t l = strlen(s) + 1;
62   char * t = new char[l];
63   strcpy(t, s);
64   return t;
65 }
66
67 inline char * my_strblkdup( const char * s ) {
68   if (s == NULL) return NULL ;
69
70   size_t l = strlen(s) + 1 ;
71   int i ;
72   for ( i = l - 2 ; i >= 0 ; i-- ) {
73     if ( s[i] != ' ' ) {
74       break ;
75     }
76     l = l - 1 ;
77   }
78   char * t = new char[l] ;
79   strncpy(t, s , l-1) ;
80   t[l-1] = '\0' ;
81   return t;
82 }
83
84 string DataStreamTypeToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ;
85 SALOME_ModuleCatalog::DataStreamType StringToDataStreamType( const char * aIdlType ) ;
86
87 string KindOfDataStreamTraceToString( SUPERV::KindOfDataStreamTrace aDataStreamTrace ) ;
88
89 string DataStreamDependencyToString( const SALOME_ModuleCatalog::DataStreamDependency aDataStreamDependency ) ;
90
91 string DataStreamToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ;
92
93 enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected ,
94                     DataConnected } ;
95
96 namespace GraphBase {
97
98   struct SCoord {
99     long theX ;
100     long theY ;
101   };
102     
103   typedef vector<SCoord> ListOfCoords;
104
105   typedef string FuncName ;
106
107   typedef vector< FuncName > ListOfFuncName ;
108
109   typedef vector<const SUPERV::ListOfStrings *> ListOfPythonFunctions ;
110
111   typedef vector<SALOME_ModuleCatalog::ServicesParameter> ListOfParameters;
112
113   struct InDataStreamParameter {
114      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
115      SUPERV::KindOfSchema                              theKindOfSchema ;
116      SUPERV::KindOfInterpolation                       theKindOfInterpolation ;
117      SUPERV::KindOfExtrapolation                       theKindOfExtrapolation ;
118    };
119   typedef vector<InDataStreamParameter> ListOfInDataStreamParameters;
120
121   struct OutDataStreamParameter {
122      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
123      long                                              theNumberOfValues ;
124    };
125   typedef vector<OutDataStreamParameter> ListOfOutDataStreamParameters;
126
127   struct SNode {
128     string                        theComponentName ;
129     string                        theInterfaceName ;
130     string                        theName ;
131     SUPERV::KindOfNode            theKind ;
132     long                          theTimeout ;
133     SUPERV::KindOfDataStreamTrace theDataStreamTrace ;
134     double                        theDeltaTime ;
135     string                        theCoupledNode ;
136 //    int                           theDataStreamInArgsNumber ;
137 //    int                           theDataStreamOutArgsNumber ;
138     SALOME_ModuleCatalog::Service theService ;
139     ListOfInDataStreamParameters  theListOfInDataStreams ;
140     ListOfOutDataStreamParameters theListOfOutDataStreams ;
141     ListOfFuncName                theListOfFuncName ;
142     ListOfPythonFunctions         theListOfPythonFunctions ;
143     SUPERV::SDate                 theFirstCreation ;
144     SUPERV::SDate                 theLastModification ;
145     string                        theEditorRelease ;
146     string                        theAuthor ;
147     string                        theContainer;
148     string                        theComment;
149     SCoord                        theCoords ;
150   };
151
152   typedef vector<SNode> ListOfNodes;
153
154   struct ServicesData {
155     SALOME_ModuleCatalog::ServicesParameter aDataParameter ;
156     CORBA::Any                              aDataValue;
157   };
158
159   typedef vector<ServicesData> ListOfServicesData;
160
161   struct SLink {
162     string       FromNodeName ;
163     string       FromServiceParameterName ;
164     string       ToNodeName ;
165     string       ToServiceParameterName ;
166     CORBA::Any   aLinkValue;
167     ListOfCoords aListOfCoords ;
168   };
169
170   typedef vector<SLink> ListOfLinks;
171
172   struct SGraph {
173     SNode        Info ;
174     ListOfNodes  Nodes ;
175     ListOfLinks  Links ;
176     ListOfLinks  Datas ;
177   };
178
179   typedef vector<SGraph> ListOfGraphs;
180
181   class Base {
182
183     private:   
184
185       CORBA::ORB_ptr _Orb ;
186
187     public:   
188
189       int      * _prof_debug ;
190       ofstream * _fdebug ;
191                      
192       Base() ;
193       virtual ~Base() {} ;
194
195       void SetDebug( CORBA::ORB_ptr ORB ,
196                      int * prof_debug , ofstream * fdebug ) ;
197
198       char * ObjectToString( CORBA::Object_ptr obj ) const ;
199       CORBA::Object_ptr StringToObject(char * obj ) const ;
200
201   } ;
202 # ifdef _DEBUG_
203
204 //             *GraphBase::Base::_fdebug << "      " /*<< setw(3*(*GraphBase::Base::_prof_debug)) */<< " "
205
206 #   define cdebug if ( GraphBase::Base::_fdebug )  *GraphBase::Base::_fdebug << "      " << " "
207
208 #   define cdebug_in if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "-->" << " "
209
210 #   define cdebug_out if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "<--" << " "
211
212 # else
213
214 #   define cdebug while (false) std::cerr
215 #   define cdebug_in  cdebug
216 #   define cdebug_out cdebug
217 #   define debugFile(x) 
218
219 # endif
220
221 } ;
222
223 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamType &);
224
225 #endif