示例#1
0
CORBA::AttributeDef_ptr
TAO_InterfaceDef_i::create_attribute_i (
    const char *id,
    const char *name,
    const char *version,
    CORBA::IDLType_ptr type,
    CORBA::AttributeMode mode
  )
{
  // This will throw an exception if a name clash is found.
  // create_common() will check for all other errors.
  this->check_inherited (name,
                         CORBA::dk_Attribute);

  TAO_Container_i::tmp_name_holder_ = name;
  ACE_Configuration_Section_Key new_key;

  // Common to all IR objects created in CORBA::Container.
  ACE_TString path =
    TAO_IFR_Service_Utils::create_common (CORBA::dk_Interface,
                                          CORBA::dk_Attribute,
                                          this->section_key_,
                                          new_key,
                                          this->repo_,
                                          id,
                                          name,
                                          &TAO_Container_i::same_as_tmp_name,
                                          version,
                                          "attrs");

  // Store the path to the attribute's type definition.
  char *type_path = TAO_IFR_Service_Utils::reference_to_path (type);

  this->repo_->config ()->set_string_value (new_key,
                                            "type_path",
                                            type_path);

  // Store the attribute's mode.
  this->repo_->config ()->set_integer_value (new_key,
                                             "mode",
                                             mode);

  // Create the object reference.
  CORBA::Object_var obj =
    TAO_IFR_Service_Utils::create_objref (CORBA::dk_Attribute,
                                          path.c_str (),
                                          this->repo_);

  CORBA::AttributeDef_var retval =
    CORBA::AttributeDef::_narrow (obj.in ());

  return retval._retn ();
}
示例#2
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;
}
示例#3
0
文件: client.cpp 项目: CCJY/ATCD
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  //init IFR objref
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      TAO_IFR_Client_Adapter *ifr_client =
        ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
          TAO_ORB_Core::ifr_client_adapter_name ());

      if (ifr_client == 0)
        {
          throw ::CORBA::INTF_REPOS ();
        }

      ACE_DEBUG ((LM_DEBUG, "Got IFR_Client ref.\n"));

      CORBA::InterfaceDef_var intDef =
        ifr_client->get_interface (orb.in (), "IDL:IFR_Test/test_if:1.0");

      if (CORBA::is_nil (intDef.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                            "get interface returned nil ref\n"),
                            1);
        }

      CORBA::ContainedSeq_var attributes =
        intDef->contents (CORBA::dk_Attribute, 1);
      CORBA::ULong n_ats = attributes->length ();

      CORBA::ULong index = 0UL;
      CORBA::String_var name = attributes[index]->name ();
      ACE_DEBUG ((LM_DEBUG,
                  "found %d attributes, name = %s\n",
                  n_ats,
                  name.in ()));

      CORBA::AttributeDef_var attr =
        CORBA::AttributeDef::_narrow (attributes[index]);

      if (CORBA::is_nil (attr.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                            "could not narrow attribute ref\n"),
                            1);
        }

      CORBA::TypeCode_var tc = attr->type ();

      ACE_DEBUG ((LM_DEBUG, "foo attr typecode = %s\n", tc->id ()));
    }
  catch (const ::CORBA::Exception &ex)
    {
      ex._tao_print_exception("ERROR : unexpected CORBA exception caugth :");
      return 1;
    }

  return 0;
}