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;
}
Exemple #2
0
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 
StandardConfiguratorImpl::configure(::Components::CCMObject_ptr comp)
throw( Components::WrongComponentType )
{
	for(CORBA::ULong i = 0; i < config_.length(); i++ )
	{
		DEBUG_OUT2( "\nStandardConfigurator: configure ", config_[i]->name() );


		// create a request according to the wire format of attribute operations
		std::string operation = "_set_";
		operation.append( config_[i]->name() );
		CORBA::Request_ptr request = comp->_request( operation.c_str() );
		request->add_in_arg() = config_[i]->value();


		// send the request
		try
		{
 			request->invoke();
		}
		catch( CORBA::SystemException& ex )
		{
 			std::cerr << "StandardConfigurator: Unexpected System Exception" << &ex << std::endl;
		}


		// check for exceptions
		CORBA::Exception* ex = request->env()->exception();
		if ( ex != 0 )
		{
			std::cerr << "StandardConfigurator: Exception during configuration : " << ex << std::endl;
		}
	}
}
Exemple #4
0
static VALUE _r2tao_set_request_return_type(CORBA::Request_ptr _req, VALUE ret_rtc)
{
  CORBA::ORB_var _orb = _req->target ()->_get_orb ();

  CORBA::TypeCode_var _ret_tc = r2tao_Typecode_r2t (ret_rtc, _orb. in());
  _req->set_return_type (_ret_tc.in ());
  return Qtrue;
}
Exemple #5
0
static VALUE _r2tao_set_request_arguments(CORBA::Request_ptr _req, VALUE arg_list)
{
  long ret_val = 0;
  CORBA::ORB_var _orb = _req->target ()->_get_orb ();

  // clear all current args
  CORBA::ULong arg_num = _req->arguments ()->count ();
  while (arg_num > 0)
    _req->arguments ()->remove (--arg_num);

  if (arg_list != Qnil)
  {
    long arg_len = RARRAY (arg_list)->len;
    for (long a=0; a<arg_len ;++a)
    {
      VALUE argspec = rb_ary_entry (arg_list, a);
      VALUE argname = rb_ary_entry (argspec, 0);
      int _arg_type = NUM2INT (rb_ary_entry (argspec, 1));
      CORBA::TypeCode_var _arg_tc = r2tao_Typecode_r2t (rb_ary_entry (argspec, 2), _orb. in());

      //::printf("arg_name=%s; arg_type=%d\n", _arg_name, _arg_type);

      if (_arg_type != r2tao_OUT_ARG)
      {
        VALUE arg_val = rb_ary_entry (argspec, 3);

        char *_arg_name = argname != Qnil ? RSTRING (argname)->ptr : 0;
        CORBA::Any& _arg = (_arg_type == r2tao_IN_ARG) ?
            (_arg_name ? _req->add_in_arg (_arg_name) : _req->add_in_arg ()) :
            (_arg_name ? _req->add_inout_arg (_arg_name) : _req->add_inout_arg ());

        if (_arg_type == r2tao_INOUT_ARG)
          ++ret_val;

        // assign value to Any
        r2tao_Typecode_Ruby2Any(_arg, _arg_tc.in (), arg_val, _orb.in ());
      }
      else
      {
        ++ret_val;
        char *_arg_name = argname != Qnil ? RSTRING (argname)->ptr : 0;
        CORBA::Any& _arg = _arg_name ?
            _req->add_out_arg (_arg_name) : _req->add_out_arg ();

        // assign type info to Any
        r2tao_Typecode_Ruby2Any(_arg, _arg_tc.in (), Qnil, _orb.in ());
      }
    }
  }
  return LONG2NUM (ret_val);
}
Exemple #6
0
static VALUE _r2tao_set_request_exceptions(CORBA::Request_ptr _req, VALUE exc_list)
{
  long exc_len = 0;
  CORBA::ORB_var _orb = _req->target ()->_get_orb ();

  // clear all current excepts
  CORBA::ULong x_num = _req->exceptions ()->count ();
  while (x_num > 0)
    _req->exceptions ()->remove (--x_num);

  if (exc_list != Qnil)
  {
    exc_len = RARRAY (exc_list)->len;
    for (long x=0; x<exc_len ;++x)
    {
      VALUE exctc = rb_ary_entry (exc_list, x);
      CORBA::TypeCode_var _xtc = r2tao_Typecode_r2t (exctc, _orb.in ());
      _req->exceptions ()->add (_xtc.in ());
    }
  }
  return LONG2NUM (exc_len);
}
Exemple #7
0
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;
  }
}