Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/superv.git] / src / GraphEditor / DataFlowEditor_DataFlow.lxx
1 #ifndef _DATAFLOWEDITOR_DATAFLOW_LXX
2 #define _DATAFLOWEDITOR_DATAFLOW_LXX
3
4 #include "DataFlowEditor_OutNode.hxx"
5
6 inline void GraphEditor::DataFlow::ReadOnly() {
7   _ReadOnly = true ;
8 }
9
10 inline char * GraphEditor::DataFlow::DataFlowInfo() {
11   ostrstream s;
12   IsValid() ;
13   GraphEditor::DataFlow::DataFlow aDataFlow = *this ;
14   s << aDataFlow << ends ;
15   return CORBA::string_dup( s.str() );
16 }
17
18 inline char * GraphEditor::DataFlow::DataNodeInfo() {
19   ostrstream s;
20   IsValid() ;
21   GraphBase::DataNode::DataNodeInfo( s ) ;
22   return CORBA::string_dup(s.str());
23 }
24
25 inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) {
26   ostrstream s;
27   if ( GetGraphNode( aNodeName ) )
28     GetGraphNode( aNodeName )->NodeInfo( s ) ;
29   else
30     s << aNodeName << " not found" << ends ;
31   return CORBA::string_dup( s.str() );
32 }
33
34 inline bool GraphEditor::DataFlow::LoadDataFlow(
35                        const GraphBase::SGraph *aDataFlow ) {
36   if ( _ReadOnly )
37     return false ;
38   return GraphEditor::OutNode::LoadDataFlow( aDataFlow ) ; 
39 } ;
40
41 inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ) {
42   if ( _ReadOnly )
43     return false ;
44   return GraphEditor::OutNode::LoadXml( myFileName ) ; 
45 } ;
46
47 inline bool GraphEditor::DataFlow::LoadInfo( const GraphBase::SNode &aDataFlowInfo ) {
48   if ( _ReadOnly )
49     return false ;
50   return GraphEditor::OutNode::LoadInfo( aDataFlowInfo ) ; 
51 } ;
52
53 inline bool GraphEditor::DataFlow::SaveXml(const char* myFileName ) {
54   return GraphEditor::OutNode::SaveXml( myFileName ) ; 
55 } ;
56
57 inline bool GraphEditor::DataFlow::SavePy(const char* myFileName ) {
58   return GraphEditor::OutNode::SavePy( myFileName ) ; 
59 } ;
60
61 // get all DataFlow informations (for a .XML file) :
62 inline GraphBase::SGraph * GraphEditor::DataFlow::GetDataFlow() {
63    return GraphEditor::OutNode::GetDataFlow() ; 
64 } ;
65
66 //    void DateModification() ;
67
68 inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const {
69    return GraphEditor::OutNode::GetInfo() ; 
70 } ;
71
72 inline GraphBase::ListOfNodes * GraphEditor::DataFlow::GetNodes() const {
73    return GraphEditor::OutNode::GetNodes() ; 
74 } ;
75
76 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const {
77    return GraphEditor::OutNode::GetLinks() ; 
78 } ;
79
80 inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const {
81    return GraphEditor::OutNode::GetGraphs() ; 
82 } ;
83
84 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const {
85    return GraphEditor::OutNode::GetDatas() ; 
86 } ;
87
88 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() {
89    IsValid() ;
90    return GraphEditor::OutNode::GetService() ; 
91 } ;
92
93 inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode(
94                       const SALOME_ModuleCatalog::Service& NodeService ,
95                       const char* NodeComponentName ,
96                       const char* NodeInterfaceName ,
97                       const char* NodeName,
98                       const SUPERV::KindOfNode NodeKindOfNode,
99                       GraphBase::ListOfFuncName aFuncName ,
100                       GraphBase::ListOfPythonFunctions aPythonFunction ,
101                       const SUPERV::SDate NodeFirstCreation,
102                       const SUPERV::SDate NodeLastModification,
103                       const char * NodeEditorRelease,
104                       const char * NodeAuthor,
105                       const char * NodeComputer,
106                       const char * NodeComment,
107                       const int NodeX,
108                       const int NodeY) {
109   if ( _ReadOnly )
110     return (GraphEditor::InNode * ) NULL ;
111   return GraphEditor::OutNode::AddNode( NodeService ,
112                                         aFuncName , aPythonFunction ,
113                                         NodeComponentName ,
114                                         NodeInterfaceName ,
115                                         NodeName , NodeKindOfNode ,
116                                         NodeFirstCreation ,
117                                         NodeLastModification ,
118                                         NodeEditorRelease ,
119                                         NodeAuthor , NodeComputer ,
120                                         NodeComment , NodeX , NodeY ) ; 
121 } ;
122
123 inline GraphEditor::InNode * GraphEditor::DataFlow::GetNode( const char* NodeName ) {
124   return GraphEditor::OutNode::GetNode( NodeName ) ; 
125 } ;
126
127 inline bool GraphEditor::DataFlow::RemoveNode( const char* NodeName ) {
128   if ( _ReadOnly )
129     return false ;
130   return GraphEditor::OutNode::RemoveNode( NodeName ) ; 
131 } ;
132
133 inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName ,
134                                                const char* NewNodeName ) {
135   if ( _ReadOnly )
136     return false ;
137   return GraphEditor::OutNode::ReNameNode( OldNodeName , NewNodeName ) ; 
138 } ;
139
140 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService(
141                                              const char * aNodeName ) {
142   if ( GetGraphNode( aNodeName ) )
143     return GetGraphNode( aNodeName )->GetService() ;
144   return NULL ;
145 }
146
147 inline void GraphEditor::DataFlow::Coordinates( const int X , const int Y ) {
148   return GraphEditor::OutNode::Coordinates( X , Y ) ; 
149 } ;
150
151 inline const int GraphEditor::DataFlow::XCoordinate() {
152    return GraphEditor::OutNode::XCoordinate() ; 
153 } ;
154
155 inline const int GraphEditor::DataFlow::YCoordinate() {
156    return GraphEditor::OutNode::YCoordinate() ; 
157 } ;
158
159 inline void GraphEditor::DataFlow::Coordinates( const char* NodeName ,
160                                                 const int X , const int Y ) {
161   return GraphEditor::OutNode::Coordinates( NodeName , X , Y ) ; 
162 } ;
163
164 inline const int GraphEditor::DataFlow::XCoordinate( const char* NodeName ) {
165    return GraphEditor::OutNode::XCoordinate( NodeName ) ; 
166 } ;
167
168 inline const int GraphEditor::DataFlow::YCoordinate( const char* NodeName ) {
169    return GraphEditor::OutNode::YCoordinate( NodeName ) ; 
170 } ;
171
172 inline const GraphBase::InPort *GraphEditor::DataFlow::GetInPort( const char *name ) {
173   return GraphEditor::OutNode::GetInPort( name ) ; 
174 }
175 inline const GraphBase::OutPort *GraphEditor::DataFlow::GetOutPort( const char *name ) {
176   return GraphEditor::OutNode::GetOutPort( name ) ; 
177 }
178 inline GraphBase::InPort *GraphEditor::DataFlow::GetChangeInPort( const char *name ) {
179   return GraphEditor::OutNode::GetChangeInPort( name ) ; 
180 }
181 inline GraphBase::OutPort *GraphEditor::DataFlow::GetChangeOutPort( const char *name ) {
182   return GraphEditor::OutNode::GetChangeOutPort( name ) ; 
183 }
184
185 inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName ) {
186   return GraphEditor::OutNode::HasInput( ToServiceParameterName ) ;
187 }
188
189 inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName ,
190                                             const char* FromServiceParameterName ,
191                                             const char* ToNodeName ,
192                                             const char* ToServiceParameterName ,
193                                             const CORBA::Any aValue ) {
194   if ( _ReadOnly )
195     return false ;
196   CORBA::Any const * theValue = GetNode( FromNodeName )->GetOutPort( FromServiceParameterName )->Value() ; // Keep the type !
197   return GraphEditor::OutNode::AddLink( FromNodeName ,
198                                         FromServiceParameterName ,
199                                         ToNodeName ,
200                                         ToServiceParameterName ,
201                                         *theValue ) ; 
202 } ;
203
204 inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName ,
205                                            const char* ToServiceParameterName ,
206                                            char** FromNodeName ,
207                                            char** FromServiceParameterName ) {
208   return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName ,
209                                         FromNodeName ,
210                                         FromServiceParameterName ) ;
211 }
212
213 inline GraphBase::SLink * GraphEditor::DataFlow::GetLink(
214                                  GraphBase::ComputingNode * aNode ,
215                                  const char* ToServiceParameterName ) {
216   return GraphBase::Graph::GetLink( aNode ,
217                                     aNode->GetChangeInPort( ToServiceParameterName ) ) ;
218 }
219
220 inline bool GraphEditor::DataFlow::AddLinkCoord(
221                          const char* FromNodeName ,
222                          const char* FromServiceParameterName ,
223                          const char* ToNodeName ,
224                          const char* ToServiceParameterName ,
225                          const int nXY ,
226                          const int* X ,
227                          const int* Y ) {
228   return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
229                                              FromServiceParameterName ,
230                                              ToNodeName ,
231                                              ToServiceParameterName ,
232                                              nXY , X , Y ) ; 
233 } ;
234
235 inline bool GraphEditor::DataFlow::AddLinkCoord(
236                          const char* FromNodeName ,
237                          const char* FromServiceParameterName ,
238                          const char* ToNodeName ,
239                          const char* ToServiceParameterName ,
240                          const int index ,
241                          const int X ,
242                          const int Y ) {
243   return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
244                                              FromServiceParameterName ,
245                                              ToNodeName ,
246                                              ToServiceParameterName ,
247                                              index , X , Y ) ; 
248 } ;
249
250 inline bool GraphEditor::DataFlow::ChangeLinkCoord(
251                          const char* FromNodeName ,
252                          const char* FromServiceParameterName ,
253                          const char* ToNodeName ,
254                          const char* ToServiceParameterName ,
255                          const int index ,
256                          const int X ,
257                          const int Y ) {
258   return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
259                                                 FromServiceParameterName ,
260                                                 ToNodeName ,
261                                                 ToServiceParameterName ,
262                                                 index , X , Y ) ; 
263 } ;
264
265 inline bool GraphEditor::DataFlow::RemoveLinkCoord(
266                          const char* FromNodeName ,
267                          const char* FromServiceParameterName ,
268                          const char* ToNodeName ,
269                          const char* ToServiceParameterName ,
270                          const int index ) {
271   return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
272                                                 FromServiceParameterName ,
273                                                 ToNodeName ,
274                                                 ToServiceParameterName ,
275                                                 index ) ; 
276 } ;
277
278 inline int GraphEditor::DataFlow::GetLinkCoordSize(
279                          const char* FromNodeName ,
280                          const char* FromServiceParameterName ,
281                          const char* ToNodeName ,
282                          const char* ToServiceParameterName ) {
283   return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName ,
284                                                  FromServiceParameterName ,
285                                                  ToNodeName ,
286                                                  ToServiceParameterName ) ; 
287 } ;
288
289 inline bool GraphEditor::DataFlow::GetLinkCoord(
290                          const char* FromNodeName ,
291                          const char* FromServiceParameterName ,
292                          const char* ToNodeName ,
293                          const char* ToServiceParameterName ,
294                          int *X , int *Y ) {
295   return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
296                                              FromServiceParameterName ,
297                                              ToNodeName ,
298                                              ToServiceParameterName ,
299                                              X , Y ) ; 
300 } ;
301
302 inline bool GraphEditor::DataFlow::GetLinkCoord(
303                          const char* FromNodeName ,
304                          const char* FromServiceParameterName ,
305                          const char* ToNodeName ,
306                          const char* ToServiceParameterName ,
307                          const int index , long &X , long &Y ) {
308   return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
309                                              FromServiceParameterName ,
310                                              ToNodeName ,
311                                              ToServiceParameterName ,
312                                              index , X , Y ) ; 
313 } ;
314
315 inline bool GraphEditor::DataFlow::RemoveLink(
316                          const char* FromNodeName ,
317                          const char* FromServiceParameterName ,
318                          const char* ToNodeName ,
319                          const char* ToServiceParameterName ) {
320   if ( _ReadOnly )
321     return false ;
322   return GraphEditor::OutNode::RemoveLink( FromNodeName ,
323                                            FromServiceParameterName ,
324                                            ToNodeName ,
325                                            ToServiceParameterName ) ; 
326 } ;
327
328 inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
329                                                  const char* ToParameterName ,
330                                                  const CORBA::Any aValue ) {
331 #if 0
332   GraphBase::Node *toNode ;
333   GraphBase::InPort *toPort ;
334   char *aNode ;
335   char *aPort ;
336   NodePort( ToNodeName , ToParameterName , &aNode , &aPort ) ;
337   toNode = GetChangeGraphNode( aNode ) ;
338   if ( toNode ) {
339     toPort = toNode->GetChangeInPort( aPort ) ;
340     if ( toPort && ( toPort->IsConnected() ||
341                      toPort->IsDataConnected() ) ) {
342       RemoveLink( toNode->Name() , toPort->PortName() ) ;
343     }
344   }
345   else {
346     toPort = NULL ;
347   }
348   delete aNode ;
349   delete aPort ;
350 #endif
351   if ( !IsValid() )
352     return false ;
353   return GraphBase::Graph::AddInputData( ToNodeName , ToParameterName ,
354                                          aValue ) ; 
355 } ;
356
357 inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 ,
358                                                       const char* ToParameterName1 ,
359                                                       const char* ToNodeName2 ,
360                                                       const char* ToParameterName2 ) {
361   if ( !IsValid() )
362     return false ;
363   return GraphEditor::OutNode::AddInputData( ToNodeName1 , ToParameterName1 ,
364                                              ToNodeName2 , ToParameterName2 ) ;
365 } ;
366
367 inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
368                                    const char * ToNodeName ,
369                                    const char * ToParameterName ) {
370   return GraphEditor::OutNode::GetInData( ToNodeName ,
371                                           ToParameterName ) ;
372 }
373 inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
374                                    const char * FromNodeName ,
375                                    const char * FromParameterName ) {
376   return GraphEditor::OutNode::GetOutData( FromNodeName ,
377                                            FromParameterName ) ;
378 }
379
380 inline bool GraphEditor::DataFlow::IsValid() {
381   return GraphEditor::OutNode::IsValid() ;
382 }
383
384 inline bool GraphEditor::DataFlow::IsExecutable() {
385   return GraphEditor::OutNode::IsExecutable() ;
386 }
387
388 inline bool GraphEditor::DataFlow::IsExecuting() {
389   if ( _DataFlowExecutor ) {
390     if ( _DataFlowExecutor->IsDone() ) {
391       _Executing = false ;
392     }
393     else {
394     _Executing = true ;
395     }
396   }
397   else {
398     _Executing = false ;
399   }
400   return _Executing ;
401 }
402
403 inline bool GraphEditor::DataFlow::IsEditing() {
404   return !IsExecuting() ;
405 }
406
407 inline bool GraphEditor::DataFlow::IsReadOnly() {
408   return _ReadOnly ;
409 }
410
411 inline long GraphEditor::DataFlow::LevelMax() {
412   if ( !IsValid() )
413     return 0 ;
414   return GraphBase::Graph::LevelMax() ;
415 }
416
417 inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
418   if ( !IsValid() )
419     return ((SUPERV::ListOfStrings * ) NULL ) ;
420   return GraphBase::Graph::LevelNodes( aLevel ) ;
421 }
422
423 inline long GraphEditor::DataFlow::ThreadsMax() {
424   if ( !IsValid() )
425     return 0 ;
426   return GraphBase::Graph::ThreadsMax() ;
427 }
428
429 inline long GraphEditor::DataFlow::GraphsNumber() {
430   if ( !IsValid() )
431     return 0 ;
432   return GraphBase::Graph::GraphsNumber() ;
433 }
434
435 inline void GraphEditor::DataFlow::Executor(
436                                GraphExecutor::DataFlow * DataFlowExecutor ) {
437   _DataFlowExecutor = DataFlowExecutor ;
438 }
439
440 inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const {
441   return _DataFlowExecutor ;
442 }
443
444 #endif
445
446
447