void
TAO_IFR_Client_Adapter_Impl::create_operation_list (
    CORBA::ORB_ptr orb,
    CORBA::OperationDef_ptr opDef,
    CORBA::NVList_ptr &result)
{
    // Create an empty NVList.
    orb->create_list (0, result);

    // Get the parameters (if any) from the OperationDef, and for each
    // parameter add a corresponding entry to the result.
    CORBA::ParDescriptionSeq_var params = opDef->params ();

    CORBA::ULong paramCount = params->length ();

    for (CORBA::ULong i = 0; i < paramCount; ++i)
    {
        CORBA::Any value;
        TAO::Unknown_IDL_Type *unk = 0;
        ACE_NEW (unk,
                 TAO::Unknown_IDL_Type (params[i].type.in ()));
        value.replace (unk);

        // Convert the parameter mode to an arg mode
        CORBA::Flags flags = 0;
        switch(params[i].mode)
        {
        case CORBA::PARAM_IN:
            flags = CORBA::ARG_IN;
            break;
        case CORBA::PARAM_OUT:
            flags = CORBA::ARG_OUT;
            break;
        case CORBA::PARAM_INOUT:
            flags = CORBA::ARG_INOUT;
            break;
        default:
            // Shouldn't happen
            throw ::CORBA::INTERNAL();
        }

        // Add an argument to the NVList.
        result->add_value (params[i].name.in (), value, flags);
    }
}
示例#2
0
CORBA::ParDescriptionSeq *
TAO_OperationDef_i::params_i (void)
{
  CORBA::ULong i = 0;
  ACE_Configuration_Section_Key params_key;
  int status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "params",
                                          0,
                                          params_key);

  ACE_Unbounded_Queue<ACE_Configuration_Section_Key> key_queue;

  // This section may not have been created.
  if (status == 0)
    {
      u_int count = 0;
      this->repo_->config ()->get_integer_value (params_key,
                                                 "count",
                                                 count);

      for (i = 0; i < count; ++i)
        {
          ACE_Configuration_Section_Key param_key;
          char *stringified = TAO_IFR_Service_Utils::int_to_string (i);
          status =
            this->repo_->config ()->open_section (params_key,
                                                  stringified,
                                                  0,
                                                  param_key);

          if (status == 0)
            {
              key_queue.enqueue_tail (param_key);
            }
        }
    }

  CORBA::ULong size = static_cast<CORBA::ULong> (key_queue.size ());

  CORBA::ParDescriptionSeq *pd_seq = 0;
  ACE_NEW_THROW_EX (pd_seq,
                    CORBA::ParDescriptionSeq (size),
                    CORBA::NO_MEMORY ());

  pd_seq->length (size);

  if (size == 0)
    {
      return pd_seq;
    }

  CORBA::ParDescriptionSeq_var retval = pd_seq;

  for (i = 0; i < size; ++i)
    {
      ACE_Configuration_Section_Key key;
      key_queue.dequeue_head (key);

      ACE_TString name;
      this->repo_->config ()->get_string_value (key,
                                                "name",
                                                name);

      retval[i].name = name.c_str ();

      u_int mode = 0;
      this->repo_->config ()->get_integer_value (key,
                                                 "mode",
                                                 mode);

      retval[i].mode = static_cast<CORBA::ParameterMode> (mode);

      ACE_TString type_path;
      this->repo_->config ()->get_string_value (key,
                                                "type_path",
                                                type_path);

      TAO_IDLType_i *impl =
        TAO_IFR_Service_Utils::path_to_idltype (type_path,
                                                this->repo_);

      // We have an undefined interface
      if (impl == 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Encountered undefined parameter type "
                                "for variable: %s\n"),
                      name.c_str ()));

          throw CORBA::INTF_REPOS ();
        }

      retval[i].type = impl->type_i ();

      CORBA::Object_var obj =
        TAO_IFR_Service_Utils::path_to_ir_object (type_path,
                                                  this->repo_);

      retval[i].type_def = CORBA::IDLType::_narrow (obj.in ());
    }

  return retval._retn ();
}
示例#3
0
OCI_APT::ArgList *
OCI_APT::OperationTable::add_interface (CORBA::InterfaceDef_ptr intDef,
					const char * desired_op)
{
	bool want_attribute = false;
	if (desired_op && desired_op[0] == '_')
		want_attribute = ACE_OS::strncmp(desired_op+2,"et_",3) == 0;

	ACE_Write_Guard<ACE_RW_Thread_Mutex>(this->lock_);
	OCI_APT::ArgList *result = 0;
	CORBA::InterfaceDefSeq_var bases = intDef->base_interfaces ();
	CORBA::String_var *derived = new CORBA::String_var[bases->length()];
	CORBA::ULong n_bases = bases->length();
	CORBA::ULong i = 0;
	for (; i <= n_bases; i++)
	{
		CORBA::String_var rep_id = intDef->id();
		if (i == 0)
		{
			OCI_APT::ArgList *al = this->add_is_a (rep_id.in());
			if (!want_attribute && desired_op && ACE_OS::strcmp("_is_a",desired_op) == 0)
				result = al;
			else
				al->remove_ref();

			al = this->add_non_existent (rep_id.in());
			if (!want_attribute && desired_op && ACE_OS::strcmp("_non_existent",desired_op) == 0)
				result = al;
			else
				al->remove_ref();
		}

		CORBA::ContainedSeq_var attributes =
			intDef->contents (CORBA::dk_Attribute,1);
		CORBA::ULong n_ats = attributes->length();
		for (CORBA::ULong at = 0; at < n_ats; ++at)
		{
			CORBA::String_var attr_name = attributes[at]->name();
			CORBA::AttributeDef_var attr =
				CORBA::AttributeDef::_narrow (attributes[at]);
			CORBA::String_var attr_op =
				CORBA::string_alloc(ACE_OS::strlen(attr_name.in()) + 5);
			ACE_OS::strcpy(attr_op.inout(),"_get_");
			ACE_OS::strcat(attr_op.inout(),attr_name.in());
			OCI_APT::Operation *op_ptr = this->find_or_add(attr_op.in());
			OCI_APT::ArgList *arg_list =
				new OCI_APT::ArgList (0, 0, false);
			arg_list->result (attr->type());
			if (want_attribute && ACE_OS::strcmp (attr_op.in(),desired_op) == 0)
			{
				arg_list->add_ref();
				result = arg_list;
			}

			op_ptr->add_set (new OpArgs(rep_id.in(),arg_list));
			for (CORBA::ULong d = 0; d < i; d++)
				op_ptr->add_set (new OpArgs(derived[d],arg_list));
			arg_list->remove_ref();

			if (attr->mode() == CORBA::ATTR_READONLY)
				continue;

			attr_op.inout()[1] = 's'; // from _get_ to _set_
			op_ptr = this->find_or_add(attr_op.in());
			arg_list =
				new OCI_APT::ArgList (1, 0, false);
			arg_list->set_arg(0, attr->type(),CORBA::ARG_IN);
			arg_list->result (CORBA::_tc_void);
			if (want_attribute && ACE_OS::strcmp (attr_op.in(),desired_op) == 0)
			{
				arg_list->add_ref();
				result = arg_list;
			}

			op_ptr->add_set (new OpArgs(rep_id.in(),arg_list));
			for (CORBA::ULong d = 0; d < i; d++)
				op_ptr->add_set (new OpArgs(derived[d],arg_list));
			arg_list->remove_ref();

		}

		CORBA::ContainedSeq_var operations =
			intDef->contents (CORBA::dk_Operation,1);

		CORBA::ULong n_ops = operations->length ();
		for (CORBA::ULong op = 0; op < n_ops; ++op)
		{
			CORBA::String_var op_name = operations[op]->name();
			OCI_APT::Operation *op_ptr = this->find_or_add(op_name.in());

			CORBA::OperationDef_var opDef =
				CORBA::OperationDef::_narrow (operations[op]);
			CORBA::ParDescriptionSeq_var params = opDef->params ();
			CORBA::ExceptionDefSeq_var excepts = opDef->exceptions();

			int is_oneway = opDef->mode() == CORBA::OP_ONEWAY;
			OCI_APT::ArgList *arg_list =
				new OCI_APT::ArgList (params->length(),
						      excepts->length(),
						      is_oneway);
			if (!is_oneway)
				arg_list->result (opDef->result());

			for (CORBA::ULong p = 0; p < params->length (); ++p)
			{
				CORBA::Flags mode = CORBA::ARG_IN;
				if (params[p].mode == CORBA::PARAM_OUT)
					mode = CORBA::ARG_OUT;
				else if (params[p].mode == CORBA::PARAM_INOUT)
					mode = CORBA::ARG_INOUT;

				arg_list->set_arg(p, params[p].type.in(),mode);
			}

			for (CORBA::ULong e = 0; e < excepts->length (); ++e)
			{
				CORBA::TypeCode_var tc = excepts[e]->type();
				arg_list->set_excep(e, tc.in());
			}

			if (!want_attribute && desired_op && ACE_OS::strcmp(op_name,desired_op) == 0)
			{
				arg_list->add_ref();
				result = arg_list;
			}

			op_ptr->add_set (new OpArgs(rep_id.in(),arg_list));
			for (CORBA::ULong d = 0; d < i; d++)
				op_ptr->add_set (new OpArgs(derived[d],arg_list));
			arg_list->remove_ref();
		}

		if (i < bases->length())
		{
			derived[i] = rep_id;
			intDef = bases[i];
		}
	}
	delete [] derived;
	return result;
}