Salome HOME
8e4ae74b8deb5be97a2c53fd352e4822a99ee33c
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_DynInvoke.cxx
1 //  SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
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_DynInvoke.cxx
25 //  Author : Marc Tajchman, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 using namespace std;
30 #include <stdarg.h>
31 #include <map>
32
33 #include "DataFlowExecutor_InNode.hxx"
34
35 using namespace CORBA ;
36
37
38
39 void GraphExecutor::InNode::DynInvoke(Engines::Component_ptr obj ,
40                                       const char *method , 
41                                       ServicesAnyData * inParams , int nInParams ,
42                                       ServicesAnyData * outParams , int nOutParams ) {
43   Request_var req = obj->_request( method ) ;
44   const char *s ;
45
46   NVList_ptr arguments =req->arguments() ;
47
48   int i ;
49
50   int n_in  = nInParams ;
51   int n_out = nOutParams ;
52
53   for ( i = 0 ; i < n_in ; i++ ) {
54     CORBA::Any & data = inParams[i].Value ;
55     s                 = inParams[i].Name.c_str() ;
56     arguments->add_value( s , data , CORBA::ARG_IN ) ;
57 #if 0
58     switch ( data.type()->kind() ) {
59     case CORBA::tk_string :
60       char * t ;
61       data >>= t ;
62       MESSAGE( "ArgIn" << i << " : " << s << " Value " << t << " (string)") ;
63       break ;
64     case CORBA::tk_double :
65       double d ;
66       data >>= d ;
67       MESSAGE( "ArgIn" << i << " : " << s << " Value " << d << " (double)") ;
68       break ;
69     case CORBA::tk_long :
70       long l ;
71       data >>= l ;
72       MESSAGE( "ArgIn" << i << " : " << s << " Value " << l << " (long)") ;
73       break ;
74     case CORBA::tk_objref :
75       MESSAGE( "ArgIn" << i << " : " << s << " Value " << "(object reference)") ;
76       break ;
77     default :
78       MESSAGE( "ArgIn" << i << " : " << s << " Value " << "(other ERROR)") ;
79     }
80     MESSAGE() ;
81 #endif
82   }
83
84   for ( i = 0 ; i < n_out ; i++ ) {
85     CORBA::Any & data = outParams[i].Value ;
86     s                 = outParams[i].Name.c_str() ;
87     arguments->add_value( s , data , CORBA::ARG_OUT ) ;
88 #if 0
89     switch ( data.type()->kind() ) {
90     case CORBA::tk_string :
91       char * t ;
92       data >>= t ;
93       MESSAGE( "ArgOut" << i << " : " << s << " Value " << t << " (string)") ;
94       break ;
95     case CORBA::tk_double :
96       double d ;
97       data >>= d ;
98       MESSAGE( "ArgOut" << i << " : " << s << " Value " << d << " (double)") ;
99       break ;
100     case CORBA::tk_long :
101       long l ;
102       data >>= l ;
103       MESSAGE( "ArgOut" << i << " : " << s << " Value " << l << " (long)") ;
104       break ;
105     case CORBA::tk_objref :
106       MESSAGE( "ArgOut" << i << " : " << s << " Value " << "(object reference)") ;
107       break ;
108     default :
109       MESSAGE( "ArgOut" << i << " : " << s << " Value " << "(other ERROR)") ;
110     }
111     MESSAGE() ;
112 #endif
113   }
114
115   req->invoke();
116
117   if( req->env()->exception() ) {
118     req->env()->exception()->_raise() ;
119     return ; // pas utile ?
120   }
121
122   for ( i = 0 ; i < n_out ; i++ ) {
123
124       outParams[i].Value = *( arguments->item( i + n_in )->value() ) ;
125   }
126
127   return;
128
129 }
130
131 void GraphExecutor::InNode::DynInvoke( Engines::Component_ptr obj ,
132                                        const char *method , 
133                                        const char * aGraphName ,
134                                        const char * aNodeName ) {
135   Request_var req = obj->_request( method ) ;
136   const char *s;
137
138   NVList_ptr arguments =req->arguments() ;
139
140   CORBA::Any graph ;
141   graph <<= aGraphName ;
142   arguments->add_value( "aGraphName" , graph , CORBA::ARG_IN ) ;
143   CORBA::Any node ;
144   node <<= aNodeName ;
145   arguments->add_value( "aNodeName" , node , CORBA::ARG_IN ) ;
146
147   req->invoke() ;
148
149   if( req->env()->exception() ) {
150     req->env()->exception()->_raise();
151   }
152   return;
153
154 }