1 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : DataFlowBase_DynInvoke.cxx
25 // Author : Marc Tajchman, CEA
33 #include "DataFlowExecutor_InNode.hxx"
35 using namespace CORBA ;
38 #define DynInvokeTrace 0
39 void GraphExecutor::InNode::DynInvoke(Engines::Component_ptr objComponent ,
41 ServicesAnyData * inParams , int nInParams ,
42 ServicesAnyData * outParams , int nOutParams ) {
43 Request_var req = objComponent->_request( method ) ;
47 NVList_ptr arguments = req->arguments() ;
51 int n_in = nInParams ;
52 int n_out = nOutParams ;
55 cdebug << ThreadNo() << "InNode::DynInvoke " << Name() << " method " << method
56 << " objComponent " << objComponent << " " << ObjectToString( objComponent )
59 // MESSAGE( aComponent << "->" << method ) ;
60 for ( i = 0 ; i < n_in ; i++ ) {
61 CORBA::Any & data = inParams[i].Value ;
62 ArgName = inParams[i].Name.c_str() ;
63 Type = data.type()->kind() ;
64 arguments->add_value( ArgName , data , CORBA::ARG_IN ) ;
67 case CORBA::tk_string : {
70 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << t << " (string)"
74 case CORBA::tk_boolean : {
76 data >>= (CORBA::Any::to_boolean ) b ;
77 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << b << " (boolean)" << endl ;
80 case CORBA::tk_char : {
82 data >>= (CORBA::Any::to_char ) c ;
83 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << (int ) c << " (char)" << endl ;
86 case CORBA::tk_short : {
89 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << s << " (short)" << endl ;
92 case CORBA::tk_long : {
95 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << l << " (CORBA::Long)" << endl ;
98 case CORBA::tk_float : {
101 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << f << " (float)" << endl ;
104 case CORBA::tk_double : {
107 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << d << " (double)" << endl ;
110 case CORBA::tk_objref : {
111 CORBA::Object_ptr obj ;
112 char * retstr = "Catched ERROR";
115 retstr = ObjectToString( obj ) ;
119 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << retstr << "(object reference)" << endl ;
123 cdebug << "ArgIn" << i << " : " << ArgName << " Value " << "(other ERROR) kind " << Type << endl ;
126 cdebug << "" << endl ;
130 for ( i = 0 ; i < n_out ; i++ ) {
131 CORBA::Any & data = outParams[i].Value ;
132 ArgName = outParams[i].Name.c_str() ;
133 Type = data.type()->kind() ;
134 arguments->add_value( ArgName , data , CORBA::ARG_OUT ) ;
137 case CORBA::tk_string : {
140 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << t << " (string)" << endl ;
143 case CORBA::tk_boolean : {
145 data >>= (CORBA::Any::to_boolean ) b ;
146 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << b << " (boolean)" << endl ;
149 case CORBA::tk_char : {
151 data >>= (CORBA::Any::to_char ) c ;
152 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << (int ) c << " (char)" << endl ;
155 case CORBA::tk_short : {
158 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << s << " (short)" << endl ;
161 case CORBA::tk_long : {
164 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << l << " (CORBA::Long)" << endl ;
167 case CORBA::tk_float : {
170 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << f << " (float)" << endl ;
173 case CORBA::tk_double : {
176 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << d << " (double)" << endl ;
179 case CORBA::tk_objref : {
180 CORBA::Object_ptr obj ;
181 char * retstr = "Catched ERROR";
184 retstr = ObjectToString( obj ) ;
188 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << retstr << "(object reference)" << endl ;
192 cdebug << "ArgOut" << i << " : " << ArgName << " Value " << "(other ERROR) kind " << Type << endl ;
195 cdebug << "" << endl ;
199 // IPAL9273, 9369, 9731 : replace blocking function invoke() with non blocking send_deferred()
200 // to provide the correct process of killing dataflow execution
201 req->send_deferred() ;
202 while( !req->poll_response() ) {}
205 if( req->env()->exception() ) {
206 req->env()->exception()->_raise() ;
207 return ; // pas utile ?
210 for ( i = 0 ; i < n_out ; i++ ) {
212 outParams[i].Value = *( arguments->item( i + n_in )->value() ) ;
219 void GraphExecutor::InNode::DynInvoke( Engines::Component_ptr obj ,
221 const char * aGraphName ,
222 const char * aNodeName ) {
223 Request_var req = obj->_request( method ) ;
225 NVList_ptr arguments =req->arguments() ;
228 graph <<= aGraphName ;
229 arguments->add_value( "aGraphName" , graph , CORBA::ARG_IN ) ;
232 arguments->add_value( "aNodeName" , node , CORBA::ARG_IN ) ;
236 if( req->env()->exception() ) {
237 req->env()->exception()->_raise();