Exemplo n.º 1
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
	{
Exemplo n.º 2
0
void
TAO_AMH_DSI_Response_Handler::invoke_reply (CORBA::NVList_ptr args,
                                            CORBA::NamedValue_ptr result)
{
  try
   {
     this->_tao_rh_init_reply ();

    // Send the return value, if any.
    if (result != 0 && result->value () != 0)
      {
        result->value ()->impl ()->marshal_value (this->_tao_out);
      }

    // Send the "inout" and "out" parameters.
    if (args != 0)
      {
        args->_tao_encode (this->_tao_out, CORBA::ARG_INOUT | CORBA::ARG_OUT);
      }
    this->_tao_rh_send_reply ();
  }
  catch (const CORBA::Exception &)
    {
      // TODO:
    }
}
Exemplo n.º 3
0
VALUE rCORBA_Request_arguments(VALUE self)
{
  CORBA::Request_ptr _req =  r2tao_Request_r2t(self);
  R2TAO_TRY
  {
    CORBA::ULong arg_len = _req->arguments ()->count ();
    VALUE rargs = rb_ary_new ();
    for (CORBA::ULong a=0; a<arg_len ;++a)
    {
      VALUE rarg = rb_ary_new ();
      CORBA::NamedValue_ptr arg = _req->arguments ()->item (a);

      rb_ary_push (rarg, rb_str_new2 (arg->name ()));
      if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_IN))
        rb_ary_push (rarg, ULONG2NUM (r2tao_IN_ARG));
      else if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_OUT))
        rb_ary_push (rarg, ULONG2NUM (r2tao_OUT_ARG));
      else if (ACE_BIT_ENABLED (arg->flags (), CORBA::ARG_INOUT))
        rb_ary_push (rarg, ULONG2NUM (r2tao_INOUT_ARG));
      CORBA::TypeCode_var atc = arg->value ()->type ();
      VALUE arg_rtc = r2tao_Typecode_t2r(atc.in (), _req->target ()->_get_orb ());
      rb_ary_push (rarg, arg_rtc);
      VALUE arg_val = r2tao_Typecode_Any2Ruby (*arg->value (), atc.in (),
                                                arg_rtc, arg_rtc,
                                                _req->target ()->_get_orb ());
      rb_ary_push (rarg, arg_val);
      rb_ary_push (rargs, rarg);
    }
    return rargs;
  }
  R2TAO_CATCH;
  return Qnil;
}
Exemplo n.º 4
0
Arquivo: NVList.cpp Projeto: CCJY/ATCD
void
CORBA::NVList::_tao_decode (TAO_InputCDR &incoming, int flag)
{
  if (TAO_debug_level > 3)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO (%P|%t) : NVList::_tao_decode\n")));
    }

  // Then unmarshal each "in" and "inout" parameter.
  ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_);

  for (i.first (); !i.done (); i.advance ())
    {
      CORBA::NamedValue_ptr *item = 0;
      (void) i.next (item);

      CORBA::NamedValue_ptr nv = *item;

      // check if it is an in or inout parameter
      // @@ this is where we assume that the NVList is coming from
      //    a Server-side request, we could probably handle both
      //    cases with a flag, but there is no clear need for that.
      if (ACE_BIT_DISABLED (nv->flags (), flag))
        {
          continue;
        }

      if (TAO_debug_level > 3)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) : NVList::_tao_decode - %C\n"),
                      nv->name ()? nv->name () : "(no name given)" ));
        }

      CORBA::Any_ptr any = nv->value ();
      any->impl ()->_tao_decode (incoming
                                );
    }
}
Exemplo n.º 5
0
void
TAO_CEC_DynamicImplementationServer::is_a (CORBA::ServerRequest_ptr request)
{
  CORBA::NVList_ptr list;

  this->typed_event_channel_->create_list (0, list);

  CORBA::Any any_1;
  any_1._tao_set_typecode(CORBA::_tc_string);

  list->add_value ("value",
                   any_1,
                   CORBA::ARG_IN);

  request->arguments (list);

  CORBA::NamedValue_ptr nv = list->item (0);

  CORBA::Any_ptr ap = nv->value ();
  const char *value = 0;
  *ap >>= value;

  if (TAO_debug_level >= 10)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("***** TAO_CEC_DynamicImplementationServer::is_a called with value %s *****\n"),
                  value));
    }

  const char *object_id =
    CORBA::_tc_Object->id ();

  if (TAO_debug_level >= 10)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("***** is_a using Server's RepositoryId %s *****\n"),
                  this->repository_id_));
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("***** is_a using base interface %s *****\n"),
                  object_id));
    }

  CORBA::Boolean result = 0;
  if (ACE_OS::strcmp (value, this->repository_id_) == 0
      || ACE_OS::strcmp (value, object_id) == 0)
    {
      result = 1;
    }
  else
    {
      CORBA::ULong num = this->typed_event_channel_->number_of_base_interfaces ();
      for (CORBA::ULong base=0; base<num; base++)
        {
          if (TAO_debug_level >= 10)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("***** is_a using base interface %s *****\n"),
                          this->typed_event_channel_->base_interfaces (base) ));
            }

          if (ACE_OS::strcmp (value, this->typed_event_channel_->base_interfaces (base) ) == 0)
            {
              result = 1;
            }
        }
    }

  if (TAO_debug_level >= 10)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("***** is_a returning %d *****\n"),
                  result));
    }

  CORBA::Any result_any;
  CORBA::Any::from_boolean from_boolean (result);
  result_any <<= from_boolean;

  request->set_result (result_any);
}
Exemplo n.º 6
0
Arquivo: NVList.cpp Projeto: CCJY/ATCD
void
CORBA::NVList::_tao_encode (TAO_OutputCDR &cdr, int flag)
{
  ACE_GUARD (TAO_SYNCH_MUTEX,
             ace_mon,
             this->lock_);

  if (this->incoming_ != 0)
    {
      if (this->max_ == 0)
        {
          // The list is empty aggressively reduce copies and just send
          // the CDR stream, we assume that
          // TAO_Server_Request::init_reply
          // has inserted appropriated padding already to make this
          // operation correct
          cdr.write_octet_array_mb (this->incoming_->start ());
          return;
        }

      // Then unmarshal each "in" and "inout" parameter.
      ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_);

      for (i.first (); !i.done (); i.advance ())
        {
          CORBA::NamedValue_ptr *item = 0;
          (void) i.next (item);

          CORBA::NamedValue_ptr nv = *item;

          if (ACE_BIT_DISABLED (nv->flags (), flag))
            {
              continue;
            }

          if (TAO_debug_level > 3)
            {
              const char* arg = nv->name ();

              if (arg == 0)
                {
                  arg = "(nil)";
                }

              TAOLIB_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("NVList::_tao_encode - parameter <%C>\n"),
                          arg));
            }
          CORBA::TypeCode_ptr tc = nv->value ()->_tao_get_typecode ();
          (void) TAO_Marshal_Object::perform_append (tc,
                                                     this->incoming_,
                                                     &cdr);
        }

      delete this->incoming_;
      this->incoming_ = 0;
      return;
    }

  // The list is already evaluated, we cannot optimize the copies, go
  // ahead with the slow way to do things.

  // Then marshal each "in" and "inout" parameter.
  ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_);

  for (i.first (); !i.done (); i.advance ())
    {
      CORBA::NamedValue_ptr *item = 0;
      (void) i.next (item);

      CORBA::NamedValue_ptr nv = *item;

      if (ACE_BIT_DISABLED (nv->flags (), flag))
        {
          continue;
        }

      nv->value ()->impl ()->marshal_value (cdr);
    }
}
Exemplo n.º 7
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    try
    {
        int failed = 0;

        ACE_DEBUG((LM_DEBUG, "Start of Client\n"));
        // Initialise ORB.
        //
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

        // Find the Interface Repository.
        //
        ACE_DEBUG((LM_DEBUG, ". Find IFR\n"));
        CORBA::Object_var ifr_obj =
            orb->resolve_initial_references( "InterfaceRepository");

        ACE_DEBUG((LM_DEBUG, ". Narrow IFR\n"));
        CORBA::Repository_var ifr = CORBA::Repository::_narrow( ifr_obj.in());

        if( CORBA::is_nil( ifr.in() ) )
        {
            ACE_DEBUG((LM_DEBUG, "Nil IFR reference\n"));
            return 1;
        }

        ACE_DEBUG((LM_DEBUG, ". Construct interface\n"));
        // Add an interface to the repository.
        //
        CORBA::InterfaceDefSeq baseInterfaces(1) ;
        baseInterfaces.length(0) ;
        CORBA::InterfaceDef_var intface =
            ifr->create_interface( "IDL:interface865:1.0",
                                   "interface865",
                                   "1.0",
                                   baseInterfaces) ;

        // Add an operation to the interface.
        // First get some useful things.
        //
        ACE_DEBUG((LM_DEBUG, ". Get primitive (void)\n"));
        CORBA::PrimitiveDef_var voidPrimitive =
            ifr->get_primitive( CORBA::pk_void) ;
        ACE_DEBUG((LM_DEBUG, ". Get primitive (char)\n"));
        CORBA::PrimitiveDef_var charPrimitive =
            ifr->get_primitive( CORBA::pk_char) ;
        ACE_DEBUG((LM_DEBUG, ". Get primitive (long)\n"));
        CORBA::PrimitiveDef_var longPrimitive =
            ifr->get_primitive( CORBA::pk_long) ;
        ACE_DEBUG((LM_DEBUG, ". Get primitive (short)\n"));
        CORBA::PrimitiveDef_var shortPrimitive =
            ifr->get_primitive( CORBA::pk_short) ;

        ACE_DEBUG((LM_DEBUG, ". create 3 parameters\n"));
        // The operation has three parameters...
        //
        CORBA::ULong numParams = 3 ;
        CORBA::ParDescriptionSeq parameters( numParams ) ;
        parameters.length( numParams ) ;

        // ... which are: in char p1...
        //
        parameters[0].name = CORBA::string_dup("p1") ;
        parameters[0].type_def =
            CORBA::PrimitiveDef::_duplicate( charPrimitive.in() ) ;
        parameters[0].type = charPrimitive->type() ;
        parameters[0].mode = CORBA::PARAM_IN ;

        // ...out long p2...
        //
        parameters[1].name = CORBA::string_dup("p2") ;
        parameters[1].type_def =
            CORBA::PrimitiveDef::_duplicate( longPrimitive.in() ) ;
        parameters[1].type = longPrimitive->type() ;
        parameters[1].mode = CORBA::PARAM_OUT ;

        // ...and inout short p3
        //
        parameters[2].name = CORBA::string_dup("p3") ;
        parameters[2].type_def =
            CORBA::PrimitiveDef::_duplicate( shortPrimitive.in() ) ;
        parameters[2].type = shortPrimitive->type() ;
        parameters[2].mode = CORBA::PARAM_INOUT ;

        // ...and no exceptions...
        //
        ACE_DEBUG((LM_DEBUG, ". create 0 excepts\n"));
        CORBA::ExceptionDefSeq exceptions( 1 ) ;
        exceptions.length( 0 ) ;

        // ...and no context ids
        //
        ACE_DEBUG((LM_DEBUG, ". create 0 cids\n"));
        CORBA::ContextIdSeq contextIds( 1 ) ;
        contextIds.length( 0 ) ;

        // Create the operation, called "f".
        //
        ACE_DEBUG((LM_DEBUG, ". create_operation\n"));
        CORBA::OperationDef_var operation =
            intface->create_operation( "IDL:interface865/f:1.0",
                                       "f",
                                       "1.0",
                                       voidPrimitive.in(),
                                       CORBA::OP_NORMAL,
                                       parameters,
                                       exceptions,
                                       contextIds) ;



        // Create operation list.
        //
        CORBA::NVList_var opList ;

        ACE_DEBUG((LM_DEBUG, "About to call create_operation_list\n"));
        orb->create_operation_list(operation.in (),
                                   opList.out()) ;

        ACE_DEBUG((LM_DEBUG, "Call to create_operation_list succeeded\n"));
        CORBA::ULong count = opList->count() ;

        if( count != numParams )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed - wrong number of elements n list\n")) ;
            failed = 1 ;
        }

        CORBA::NamedValue_ptr nv = opList->item( 0 ) ;
        if(ACE_OS::strcmp( nv->name(), "p1") != 0 )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 1 wrong name\n"));
            failed = 1 ;
        }

        CORBA::Boolean const eq_char =
            nv->value()->type()->equal (CORBA::_tc_char);

        if( !eq_char  )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 1 wrong type\n"));
            failed = 1 ;
        }
        if( nv->flags() != CORBA::ARG_IN )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 1 wrong mode\n"));
            failed = 1 ;
        }

        nv = opList->item( 1 ) ;
        if(ACE_OS::strcmp( nv->name(), "p2") != 0 )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 2 wrong name\n"));
            failed = 1 ;
        }

        CORBA::Boolean const eq_long =
            nv->value()->type()->equal (CORBA::_tc_long);

        if( !eq_long  )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 2 wrong type\n"));
            failed = 1 ;
        }
        if( nv->flags() != CORBA::ARG_OUT )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 2 wrong mode\n"));
            failed = 1 ;
        }

        nv = opList->item( 2 ) ;
        if(ACE_OS::strcmp( nv->name(), "p3") != 0 )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 3 wrong name\n"));
            failed = 1 ;
        }

        CORBA::Boolean const eq_short =
            nv->value()->type()->equal (CORBA::_tc_short);

        if( !eq_short  )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 3 wrong type\n"));
            failed = 1 ;
        }
        if( nv->flags() != CORBA::ARG_INOUT )
        {
            ACE_DEBUG((LM_DEBUG, "Test failed: param 3 wrong mode\n"));
            failed = 1 ;
        }

        // opList->free();
        //operation->destroy();

        // Finally destroy the interface.
        //
        intface->destroy() ;

        //orb->destroy();

        if( failed == 1 )
        {
            return 1 ;
        }
        ACE_DEBUG((LM_DEBUG, ". seems OK\n"));
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Exception - test failed:\n");
        return 1;
    }
    catch (...)
    {
        ACE_DEBUG((LM_DEBUG, "An unknown exception occured - test failed\n"));
        return 1;
    }


    return 0 ;
}