Exemplo n.º 1
0
CORBA::InterfaceDefSeq *
TAO_ComponentDef_i::supported_interfaces_i (void)
{
  CORBA::InterfaceDefSeq *seq = 0;
  ACE_NEW_RETURN (seq,
                  CORBA::InterfaceDefSeq (0),
                  0);
  CORBA::InterfaceDefSeq_var retval = seq;
  retval->length (0);

  CORBA::ULong count = 0;
  ACE_Configuration_Section_Key supported_key;
  int status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "supported",
                                          0,
                                          supported_key);

  if (status == 0)
    {
      this->repo_->config ()->get_integer_value (supported_key,
                                                 "count",
                                                 count);
      retval->length (count);
      char *stringified = 0;
      ACE_TString path;
      CORBA::Object_var tmp;

      for (CORBA::ULong i = 0; i < count; ++i)
        {
          stringified = TAO_IFR_Service_Utils::int_to_string (i);
          this->repo_->config ()->get_string_value (supported_key,
                                                    stringified,
                                                    path);
          tmp =
            TAO_IFR_Service_Utils::path_to_ir_object (path,
                                                      this->repo_);

          retval[i] = CORBA::InterfaceDef::_narrow (tmp.in ());
        }
    }

  return retval._retn ();
}
Exemplo n.º 2
0
CORBA::Boolean
TAO_InterfaceDef_i::is_a_i (const char *interface_id)
{
  if (ACE_OS::strcmp (interface_id, "IDL:omg.org/CORBA/Object:1.0") == 0)
    {
      return 1;
    }

  ACE_TString id;
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "id",
                                            id);

  // Is it our type?
  if (ACE_OS::strcmp (id.fast_rep (), interface_id) == 0)
    {
      return 1;
    }

  // Is it one of our ancestors' types?
  CORBA::InterfaceDefSeq_var bases =
    this->base_interfaces_i ();

  CORBA::ULong length = bases->length ();

  PortableServer::ObjectId_var oid;
  char *base_path = 0;
  ACE_Configuration_Section_Key base_key;

  for (CORBA::ULong i = 0; i < length; ++i)
    {
      base_path = TAO_IFR_Service_Utils::reference_to_path (bases[i]);

      this->repo_->config ()->expand_path (this->repo_->root_key (),
                                           base_path,
                                           base_key,
                                           0);

      TAO_InterfaceDef_i impl (this->repo_);
      impl.section_key (base_key);

      CORBA::Boolean success = impl.is_a_i (interface_id);

      if (success == 1)
        {
          return 1;
        }
    }

  return 0;
}
Exemplo n.º 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;
}
Exemplo n.º 4
0
CORBA::Contained::Description *
TAO_InterfaceDef_i::describe_i (void)
{
  CORBA::Contained::Description *desc_ptr = 0;
  ACE_NEW_THROW_EX (desc_ptr,
                    CORBA::Contained::Description,
                    CORBA::NO_MEMORY ());

  CORBA::Contained::Description_var retval = desc_ptr;

  retval->kind = this->def_kind ();

  CORBA::InterfaceDescription ifd;
  ACE_TString holder;

  this->repo_->config ()->get_string_value (this->section_key_,
                                            "name",
                                            holder);
  ifd.name = holder.fast_rep ();
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "id",
                                            holder);
  ifd.id = holder.fast_rep ();
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "container_id",
                                            holder);
  ifd.defined_in = holder.fast_rep ();
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "version",
                                            holder);
  ifd.version = holder.fast_rep ();

  CORBA::ULong i = 0;
  CORBA::InterfaceDefSeq_var bases =
    this->base_interfaces_i ();

  CORBA::ULong length = bases->length ();
  CORBA::RepositoryIdSeq repo_ids (length);
  repo_ids.length (length);

  char *base_path = 0;
  ACE_Configuration_Section_Key base_key;

  for (i = 0; i < length; ++i)
    {
      base_path = TAO_IFR_Service_Utils::reference_to_path (bases[i]);

      this->repo_->config ()->expand_path (this->repo_->root_key (),
                                           base_path,
                                           base_key,
                                           0);

      TAO_InterfaceDef_i impl (this->repo_);
      impl.section_key (base_key);

      repo_ids[i] = impl.id_i ();
    }

  ifd.base_interfaces = repo_ids;
  retval->value <<= ifd;
  return retval._retn ();
}
Exemplo n.º 5
0
CORBA::InterfaceDef::FullInterfaceDescription *
TAO_InterfaceDef_i::describe_interface_i (void)
{
  CORBA::InterfaceDef::FullInterfaceDescription *fifd = 0;
  ACE_NEW_RETURN (fifd,
                  CORBA::InterfaceDef::FullInterfaceDescription,
                  0);

  CORBA::InterfaceDef::FullInterfaceDescription_var retval = fifd;

  ACE_TString holder;

  this->repo_->config ()->get_string_value (this->section_key_,
                                            "name",
                                            holder);
  fifd->name = holder.fast_rep ();
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "id",
                                            holder);
  fifd->id = holder.fast_rep ();

  this->repo_->config ()->get_string_value (this->section_key_,
                                            "container_id",
                                            holder);

  fifd->defined_in = holder.fast_rep ();
  this->repo_->config ()->get_string_value (this->section_key_,
                                            "version",
                                            holder);
  fifd->version = holder.fast_rep ();

  CORBA::ULong i = 0;
  CORBA::ULong j = 0;
  ACE_Unbounded_Queue<ACE_Configuration_Section_Key> key_queue;

  // Store our section key for later restoration after we have
  // traversed entries for inherited interfaces.
  ACE_Configuration_Section_Key key_holder = this->section_key_;

  // Operations
  this->inherited_operations (key_queue);

  // Restore our original section key.
  //   I am not sure this is needed but it will not hurt.
  this->section_key (key_holder);

  ACE_Configuration_Section_Key ops_key, op_key;
  int status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "ops",
                                          0,
                                          ops_key);

  CORBA::ULong count = 0;

  if (status == 0)
    {
      this->repo_->config ()->get_integer_value (ops_key,
                                                 "count",
                                                 count);

      for (j = 0; j < count; ++j)
        {
          char *stringified = TAO_IFR_Service_Utils::int_to_string (j);
          status =
            this->repo_->config ()->open_section (ops_key,
                                                  stringified,
                                                  0,
                                                  op_key);

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

  CORBA::ULong size = static_cast<CORBA::ULong> (key_queue.size ());
  fifd->operations.length (size);

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

      TAO_OperationDef_i op (this->repo_);
      op.section_key (key);

      op.make_description (fifd->operations[i]);
    }

  // Restore our original section key.
  //   It may have been overwritten by a superclass key as part of the
  //   make_description() call.
  this->section_key (key_holder);

  // Attributes
  this->inherited_attributes (key_queue);

  // Restore our original section key.
  //   I am not sure this is needed but it will not hurt.
  this->section_key (key_holder);

  ACE_Configuration_Section_Key attrs_key;
  status =
    this->repo_->config ()->open_section (this->section_key_,
                                          "attrs",
                                          0,
                                          attrs_key);

  count = 0;

  if (status == 0)
    {
      this->repo_->config ()->get_integer_value (attrs_key,
                                                 "count",
                                                 count);

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

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

  size = static_cast<CORBA::ULong> (key_queue.size ());
  fifd->attributes.length (size);

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

      TAO_AttributeDef_i attr (this->repo_);
      attr.section_key (key);

      attr.make_description (fifd->attributes[i]);
    }

  // Restore our original section key.
  //   It may have been overwritten by a superclass key as part of the
  //   make_description() call.
  this->section_key (key_holder);

  CORBA::InterfaceDefSeq_var bases =
    this->base_interfaces_i ();

  CORBA::ULong length = bases->length ();

  CORBA::RepositoryIdSeq repo_ids (length);

  repo_ids.length (length);

  PortableServer::ObjectId_var oid;
  char *base_path = 0;
  ACE_Configuration_Section_Key base_key;

  for (i = 0; i < length; ++i)
    {
      base_path = TAO_IFR_Service_Utils::reference_to_path (bases[i]);

      this->repo_->config ()->expand_path (this->repo_->root_key (),
                                           base_path,
                                           base_key,
                                           0);

      TAO_InterfaceDef_i impl (this->repo_);
      impl.section_key (base_key);

      repo_ids[i] = impl.id_i ();
    }

  fifd->base_interfaces = repo_ids;

  fifd->type = this->type_i ();

  return retval._retn ();
}