Salome HOME
MPV: Merge V1_2d
[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 enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected ,
85                     DataConnected } ;
86
87 namespace GraphBase {
88
89   struct SCoord {
90     long theX ;
91     long theY ;
92   };
93     
94   typedef vector<SCoord> ListOfCoords;
95
96   typedef string FuncName ;
97
98   typedef vector< FuncName > ListOfFuncName ;
99
100   typedef vector<const SUPERV::ListOfStrings *> ListOfPythonFunctions ;
101
102   struct NodeParameter {
103     SALOME_ModuleCatalog::ServicesParameter theInParameter ;
104     SALOME_ModuleCatalog::ServicesParameter theOutParameter ;
105   };
106
107   typedef vector<NodeParameter> ListOfParameters;
108
109   struct SNode {
110     string                        theComponentName ;
111     string                        theInterfaceName ;
112     string                        theName ;
113     SUPERV::KindOfNode            theKind ;
114     string                        theCoupledNode ;
115     SALOME_ModuleCatalog::Service theService ;
116     ListOfParameters              theListOfParameters ;
117     ListOfFuncName                theListOfFuncName ;
118     ListOfPythonFunctions         theListOfPythonFunctions ;
119     SUPERV::SDate                 theFirstCreation ;
120     SUPERV::SDate                 theLastModification ;
121     string                        theEditorRelease ;
122     string                        theAuthor ;
123     string                        theContainer;
124     string                        theComment;
125     SCoord                        theCoords ;
126   };
127
128   typedef vector<SNode> ListOfNodes;
129
130   struct ServicesData {
131     SALOME_ModuleCatalog::ServicesParameter aDataParameter ;
132     CORBA::Any                              aDataValue;
133   };
134
135   typedef vector<ServicesData> ListOfServicesData;
136
137   struct SLink {
138     string       FromNodeName ;
139     string       FromServiceParameterName ;
140     string       ToNodeName ;
141     string       ToServiceParameterName ;
142     CORBA::Any   aLinkValue;
143     ListOfCoords aListOfCoords ;
144   };
145
146   typedef vector<SLink> ListOfLinks;
147
148   struct SGraph {
149     SNode        Info ;
150     ListOfNodes  Nodes ;
151     ListOfLinks  Links ;
152     ListOfLinks  Datas ;
153   };
154
155   typedef vector<SGraph> ListOfGraphs;
156
157   class Base {
158
159     private:   
160
161       CORBA::ORB_ptr _Orb ;
162
163     public:   
164
165       int      * _prof_debug ;
166       ofstream * _fdebug ;
167                      
168       Base() ;
169       virtual ~Base() {} ;
170
171       void SetDebug( CORBA::ORB_ptr ORB ,
172                      int * prof_debug , ofstream * fdebug ) ;
173
174       char * ObjectToString( CORBA::Object_ptr obj ) const ;
175       CORBA::Object_ptr StringToObject(char * obj ) const ;
176
177   } ;
178 # ifdef _DEBUG_
179
180 //             *GraphBase::Base::_fdebug << "      " /*<< setw(3*(*GraphBase::Base::_prof_debug)) */<< " "
181
182 #   define cdebug if ( GraphBase::Base::_fdebug )  *GraphBase::Base::_fdebug << "      " << " "
183
184 #   define cdebug_in if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "-->" << " "
185
186 #   define cdebug_out if ( GraphBase::Base::_fdebug ) *GraphBase::Base::_fdebug << endl << "<--" << " "
187
188 # else
189
190 #   define cdebug while (false) std::cerr
191 #   define cdebug_in  cdebug
192 #   define cdebug_out cdebug
193 #   define debugFile(x) 
194
195 # endif
196
197 } ;
198
199 #endif