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