Salome HOME
Merge with version on tag OCC-V2_1_0d
[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 enum StatusOfPort { NotConnected , PortConnected ,
95                     DataConnected , ExternConnected } ;
96
97 namespace GraphBase {
98
99   struct SCoord {
100     long theX ;
101     long theY ;
102   };
103     
104   typedef vector<SCoord> ListOfCoords;
105
106   typedef string FuncName ;
107
108   typedef vector< FuncName > ListOfFuncName ;
109
110   typedef vector<const SUPERV::ListOfStrings *> ListOfPythonFunctions ;
111
112   typedef vector<SALOME_ModuleCatalog::ServicesParameter> ListOfParameters;
113
114   struct InDataStreamParameter {
115      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
116      SUPERV::KindOfSchema                              theKindOfSchema ;
117      SUPERV::KindOfInterpolation                       theKindOfInterpolation ;
118      SUPERV::KindOfExtrapolation                       theKindOfExtrapolation ;
119    };
120   typedef vector<InDataStreamParameter> ListOfInDataStreamParameters;
121
122   struct OutDataStreamParameter {
123      SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ;
124      long                                              theNumberOfValues ;
125    };
126   typedef vector<OutDataStreamParameter> ListOfOutDataStreamParameters;
127
128   struct SNode {
129     string                        theComponentName ;
130     string                        theInterfaceName ;
131     string                        theName ;
132     SUPERV::KindOfNode            theKind ;
133     long                          theTimeout ;
134     SUPERV::KindOfDataStreamTrace theDataStreamTrace ;
135     double                        theDeltaTime ;
136     string                        theCoupledNode ;
137 //    int                           theDataStreamInArgsNumber ;
138 //    int                           theDataStreamOutArgsNumber ;
139     SALOME_ModuleCatalog::Service theService ;
140     ListOfInDataStreamParameters  theListOfInDataStreams ;
141     ListOfOutDataStreamParameters theListOfOutDataStreams ;
142     ListOfFuncName                theListOfFuncName ;
143     ListOfPythonFunctions         theListOfPythonFunctions ;
144     SUPERV::SDate                 theFirstCreation ;
145     SUPERV::SDate                 theLastModification ;
146     string                        theEditorRelease ;
147     string                        theAuthor ;
148     string                        theContainer;
149     string                        theComment;
150     SCoord                        theCoords ;
151   };
152
153   typedef vector<SNode> ListOfSNodes;
154
155   struct ServicesData {
156     SALOME_ModuleCatalog::ServicesParameter aDataParameter ;
157     CORBA::Any                              aDataValue;
158   };
159
160   typedef vector<ServicesData> ListOfServicesData;
161
162   struct SLink {
163     string       FromNodeName ;
164     string       FromServiceParameterName ;
165     string       ToNodeName ;
166     string       ToServiceParameterName ;
167     CORBA::Any   aLinkValue;
168     ListOfCoords aListOfCoords ;
169   };
170
171   typedef vector<SLink> ListOfSLinks;
172
173   struct SGraph {
174     SNode        Info ;
175     ListOfSNodes  Nodes ;
176     ListOfSLinks  Links ;
177     ListOfSLinks  Datas ;
178   };
179
180   typedef vector<SGraph> ListOfSGraphs;
181
182   class Base {
183
184     private:   
185
186       CORBA::ORB_ptr _Orb ;
187
188     public:   
189
190       int      * _prof_debug ;
191       ofstream * _fdebug ;
192                      
193       Base() ;
194       virtual ~Base() {} ;
195
196       void SetDebug( CORBA::ORB_ptr ORB ,
197                      int * prof_debug , ofstream * fdebug ) ;
198
199       char * ObjectToString( CORBA::Object_ptr obj ) const ;
200       CORBA::Object_ptr StringToObject(char * obj ) const ;
201
202   } ;
203
204 # ifdef _DEBUG_
205
206 #   define cdebug if ( GraphBase::Base::_fdebug )  *GraphBase::Base::_fdebug << "      "
207 #   define cdebug_in if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "-->" << " "
208 #   define cdebug_out if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "<--" << " "
209
210 # else
211
212 #   define cdebug while (false) std::cerr
213 #   define cdebug_in  cdebug
214 #   define cdebug_out cdebug
215 #   define debugFile(x) 
216
217 #endif
218
219 } ;
220
221 ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamType &);
222
223 #endif