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