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