void Connection::Cb_Cmd_Request(CORBA::Request_ptr req,Tango::CallBack *cb_ptr) { DeviceData data_out; Tango::DevErrorList errors(2); errors.length(0); CORBA::NVList_ptr req_arg = req->arguments(); const char *cmd = NULL; CORBA::NamedValue_ptr nv = req_arg->item(0); *(nv->value()) >>= cmd; // // Check if the reply is an exception // CORBA::Environment_ptr env = req->env(); if (!CORBA::is_nil(env) && (env->exception() == NULL)) { // // Get received value // const CORBA::Any *received; CORBA::Any &dii_any = req->return_value(); dii_any >>= received; CORBA::Any *server_any = new CORBA::Any(*received); data_out.any = server_any; } else {
void reportResult(CORBA::Request_ptr request) { Miro::Client client; Miro::AnyPrinter printer(printName, printType, printLength, printEnums, printTc, printId); CORBA::NVList_ptr arguments = request->arguments(); for (CORBA::ULong i = 0; i < arguments->count(); ++i) { cout << "argument name: " << arguments->item(i)->name() << endl; CORBA::Any_ptr any = arguments->item(i)->value(); printer.print(cout, *any); cout << endl; } cout << "return value: " << endl; CORBA::Any any = request->return_value(); printer.print(cout, any); cout << endl; }
static VALUE _r2tao_invoke_request(CORBA::Request_ptr _req, bool& _raise) { CORBA::ULong ret_num = 0; // get the ORB we're using for the request CORBA::ORB_var _orb = _req->target ()->_get_orb (); CORBA::TypeCode_var _ret_tc = _req->return_value ().type (); // invoke twoway if resulttype specified (could be void!) if (_ret_tc->kind () != CORBA::tk_null) { if (_ret_tc->kind () != CORBA::tk_void) ++ret_num; CORBA::ULong arg_num = _req->arguments ()->count (); for (CORBA::ULong a=0; a<arg_num ;++a) { CORBA::NamedValue_ptr _arg = _req->arguments ()->item (a); if (ACE_BIT_DISABLED (_arg->flags (), CORBA::ARG_IN)) ++ret_num; } // invoke request try { _req->invoke (); } catch (CORBA::UnknownUserException& user_ex) { CORBA::Any& _excany = user_ex.exception (); CORBA::ULong exc_len = _req->exceptions ()->count (); for (CORBA::ULong x=0; x<exc_len ;++x) { CORBA::TypeCode_var _xtc = _req->exceptions ()->item (x); if (ACE_OS::strcmp (_xtc->id (), _excany._tao_get_typecode ()->id ()) == 0) { VALUE x_rtc = r2tao_Typecode_t2r(_xtc.in (), _orb.in ()); VALUE rexc = r2tao_Typecode_Any2Ruby (_excany, _xtc.in (), x_rtc, x_rtc, _orb.in ()); _raise = true; return rexc; } } // rethrow if we were not able to identify the exception // will be caught and handled in outer exception handler throw; } // handle result and OUT arguments VALUE result = (ret_num>1 ? rb_ary_new () : Qnil); if (_ret_tc->kind () != CORBA::tk_void) { CORBA::Any& retval = _req->return_value (); VALUE result_type = r2tao_Typecode_t2r(_ret_tc.in (), _orb.in ()); // return value if (ret_num>1) rb_ary_push (result, r2tao_Typecode_Any2Ruby (retval, _ret_tc.in (), result_type, result_type, _orb.in ())); else result = r2tao_Typecode_Any2Ruby (retval, _ret_tc.in (), result_type, result_type, _orb.in ()); --ret_num; // return value handled } // (in)out args if (ret_num > 0) { for (CORBA::ULong a=0; a<arg_num ;++a) { CORBA::NamedValue_ptr _arg = _req->arguments ()->item (a); if (ACE_BIT_DISABLED (_arg->flags (), CORBA::ARG_IN)) { CORBA::TypeCode_var _arg_tc = _arg->value ()->type (); VALUE arg_rtc = r2tao_Typecode_t2r(_arg_tc.in (), _orb.in ()); if (result != Qnil) rb_ary_push (result, r2tao_Typecode_Any2Ruby (*_arg->value (), _arg_tc.in (), arg_rtc, arg_rtc, _orb.in ())); else result = r2tao_Typecode_Any2Ruby (*_arg->value (), _arg_tc.in (), arg_rtc, arg_rtc, _orb.in ()); } } } return result; } else // invoke oneway { // oneway _req->send_oneway (); return Qtrue; } }