Beispiel #1
0
PortableGroup::ObjectGroup_ptr
TAO::PG_Object_Group::add_member_to_iogr (CORBA::Object_ptr member)
{
  // assume internals is locked

  PortableGroup::ObjectGroup_var result;

 ////////////////////////////
  // @@ HACK ALERT
  // The PortableGroup::ObjectGroupManager creates an object reference
  // containing a dummy entry so it will have a place to store the
  // tagged group component. If this is the first entry, we need to
  // remove that entry once we have a *real* member. This can be
  // avoided when we get support for TAG_MULTIPLE_COMPONENTS.   For
  // now, we already have a copy of the tagGroupTagged component and
  // we're going to use it below wen we increment the group version so
  // we can clean out the dummy entry.
  PortableGroup::ObjectGroup_var cleaned =
    PortableGroup::ObjectGroup::_duplicate (this->reference_.in ());
  if (this->empty_)
    {
      // remove the original profile.  It's a dummy entry supplied by
      // create_object.
      cleaned =
        this->manipulator_.remove_profiles (cleaned.in (),
                                            this->reference_.in ());
      this->empty_ = 0;
    }

  // create a list of references to be merged
  TAO_IOP::TAO_IOR_Manipulation::IORList iors (2);
  iors.length (2);
  iors [0] = CORBA::Object::_duplicate (cleaned.in());
  iors [1] = CORBA::Object::_duplicate (member);

  // Now merge the list into one new IOGR
  result =
    this->manipulator_.merge_iors (iors);
  return result._retn ();
}
Beispiel #2
0
int FTAPP::FT_Creator::run (void)
{
  int result = 0;
  size_t typeCount = this->create_roles_.size();
  size_t nType = 0;
  for ( nType = 0; result == 0 && nType < typeCount; ++nType)
  {
    const char * role = this->create_roles_[nType].c_str();
    ACE_OS::fprintf (stdout, "\nCreator: Creating group of %s\n", role);
    PortableGroup::ObjectGroup_var group = this->creator_.create_group (
      role,
      this->write_iors_);

    if (this->write_iogr_)
    {
      CORBA::String_var iogr = this->orb_->object_to_string (group.in ());

      char iogr_filename[1000];
      ACE_OS::snprintf (iogr_filename, sizeof(iogr_filename),
        "%s%s_" ACE_SIZE_T_FORMAT_SPECIFIER_ASCII ".iogr",
        this->prefix_.c_str (),
        role,
        this->iogr_seq_);
      FILE * iogr_file = ACE_OS::fopen (iogr_filename, "w");
      if (iogr_file != 0)
      {
        char const * siogr = static_cast<const char *> (iogr.in ());
        ACE_OS::fwrite (siogr, 1, ACE_OS::strlen(siogr), iogr_file);
        ACE_OS::fclose (iogr_file);
      }
      else
      {
        ACE_OS::fprintf (stderr, "Can't open iogr output file %s\n", iogr_filename);
        result = 1;
      }
    }

    if(this->ns_register_)
    {
      char iogr_name[1000];
      ACE_OS::snprintf (iogr_name, sizeof(iogr_name),
        "%s_%s_" ACE_SIZE_T_FORMAT_SPECIFIER_ASCII,
        this->prefix_.c_str (),
        role,
        this->iogr_seq_);

      CosNaming::Name this_name (1);
      this_name.length (1);
      this_name[0].id = CORBA::string_dup (iogr_name);

      this->naming_context_->rebind (this_name, group.in());
    }

    iogr_seq_ += 1;

  }

  typeCount = this->unregister_roles_.size();
  for ( nType = 0; result == 0 && nType < typeCount; ++nType)
  {
    const char * role = this->unregister_roles_[nType].c_str();
    result = this->creator_.unregister_role (role);
  }

  return result;
}