int compare(const ACE_Vector<T>& v1,
            const ACE_Vector<T>& v2,
            const size_t from_ndx,
            const size_t to_ndx)
{
  size_t last1 = v1.size () - 1;
  size_t last2 = v2.size () - 1;
  if (last1 < from_ndx || last1 < to_ndx)
    {
      return false;
    }
  if (last2 < from_ndx || last2 < to_ndx)
    {
      return false;
    }
  if (last1 != last2)
    {
      return false;
    }

  //  cout<<"compare() <================="<<endl;
  for (size_t i = from_ndx; i <= to_ndx; ++i)
    {
      //     cout<<"V1["<<i<<"]="<<v1[i];
      //     cout<<", V2["<<i<<"]="<<v2[i];
      //     cout<<": NOT EQUAL == "<<(v1[i]!=v2[i])<<endl;
      if (v1[i] != v2[i])
	{
	  return false;
	}
    }
  //  cout<<"compare() ====================>"<<endl;
  return true;
}
// Compare this vector with <s> for equality.
template <class T, size_t DEFAULT_SIZE> int
ACE_Vector<T, DEFAULT_SIZE>::operator== (const ACE_Vector<T, DEFAULT_SIZE> &s) const
{
  if (this == &s)
    return 1;
  else if (this->size () != s.size ())
    return 0;

  for (size_t slot = 0; slot < s.size (); slot++)
    if ((*this)[slot] != s[slot])
      return 0;

  return 1;
}
Exemple #3
0
// Compare this vector with <s> for equality.
template <class T, size_t DEFAULT_SIZE> bool
ACE_Vector<T, DEFAULT_SIZE>::operator== (const ACE_Vector<T, DEFAULT_SIZE> &s) const
{
  if (this == &s)
    return true;
  else if (this->size () != s.size ())
    return false;

  const size_t len = s.size ();
  for (size_t slot = 0; slot < len; ++slot)
    if ((*this)[slot] != s[slot])
      return false;

  return true;
}
void
ImR_Locator_i::shutdown
(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
 CORBA::Boolean activators, CORBA::Boolean servers)
{
  this->pinger_.shutdown ();
  this->aam_active_.reset ();
  this->aam_terminating_.reset ();
  if (servers != 0 && this->repository_->servers ().current_size () > 0)
    {
      // Note : shutdown is oneway, so we can't throw
      ORBSVCS_ERROR ((
        LM_ERROR,
        ACE_TEXT ("(%P|%t) ImR: Shutdown of all servers not implemented.\n")));
    }
  if (activators != 0 && this->repository_->activators ().current_size () > 0)
    {
      ACE_Vector<ImplementationRepository::Activator_var> acts;
      Locator_Repository::AIMap::ENTRY* entry = 0;
      Locator_Repository::AIMap::ITERATOR it (this->repository_->activators ());
      for (;it.next (entry) != 0; it.advance ())
        {
          Activator_Info_Ptr info = entry->int_id_;
          ACE_ASSERT (! info.null ());
          this->connect_activator (*info);
          if (! CORBA::is_nil (info->activator.in ()))
            acts.push_back (info->activator);
        }

      int shutdown_errs = 0;

      for (size_t i = 0; i < acts.size (); ++i)
        {
          try
            {
              acts[i]->shutdown ();
              acts[i] = ImplementationRepository::Activator::_nil ();
            }
          catch (const CORBA::Exception& ex)
            {
              ++shutdown_errs;
              if (debug_ > 1)
                {
                  ex._tao_print_exception (
                    ACE_TEXT ("(%P|%t) ImR: shutdown activator"));
                }
            }
        }
      if (debug_ > 0 && shutdown_errs > 0)
        {
          ORBSVCS_DEBUG (( LM_DEBUG,
                           ACE_TEXT ("(%P|%t) ImR: Some activators could not be shut down.\n")));
        }
    }
  // Technically, we should wait for all the activators to unregister, but
  // ,for now at least, it doesn't seem worth it.
  this->shutdown (false);

  _tao_rh->shutdown ();
}
int KasparPose::getPoseFrom(string name, ACE_Vector<KasparPose> poses)
{
	int i = -1;
	for(i = 0; i < poses.size(); i++)
	{
		if(name.compare(poses[i].getName()) == 0)
		{
			return i;
		}
	}
	return -1;
}
Exemple #6
0
// local helper function for TAO_IIOP_Endpoint::find_preferred_interfaces
static void
TAO_IIOP_Endpoint_none_duplicate_insert (
  const ACE_CString &value,
  ACE_Vector<ACE_CString> &vector)
{
  bool found= false;
  for (size_t x= 0u; x < vector.size (); ++x)
    if (vector[x] == value)
      {
        found= true;
        break;
      }
  if (!found)
    vector.push_back (value);
}
Exemple #7
0
wchar_t*
ACE_Process::convert_env_buffer (const char* env) const
{
  // Total starts out at 1 due to the final block nul terminator
  size_t total = 1;

  // Convert each individual character string to the equivalent wide
  // character string.
  ACE_Vector<wchar_t*> buffer;
  size_t start = 0;
  size_t i = 0;
  while (true)
    {
      if (env[i] == '\0')
        {
          // Convert the char string to wchar_t
          wchar_t* str = ACE_Ascii_To_Wide::convert (env + start);

          // Add the length of the string plus the nul terminator
          total += ACE_OS::strlen (str) + 1;

          // Save it and set up for the next string
          buffer.push_back (str);
          start = ++i;
          if (env[start] == '\0')
            break;
        }
      else
        {
          i += ACE_OS::strlen (env + i);
        }
    }

  // Copy each string into the buffer leaving a nul terminator between
  // each string and adding a second nul terminator at the end
  start = 0;
  wchar_t* wenv = new wchar_t[total];
  size_t length = buffer.size ();
  for (i = 0; i < length; ++i)
    {
      ACE_OS::strcpy(wenv + start, buffer[i]);
      start += ACE_OS::strlen (buffer[i]) + 1;
      delete [] buffer[i];
    }
  wenv[start] = 0;
  return wenv;
}
Exemple #8
0
CORBA::ULong
TAO_IIOP_Endpoint::preferred_interfaces (const char *csv,
                                         bool enforce,
                                         TAO_IIOP_Profile &profile)
{
  ACE_Vector<ACE_CString> preferred;
  find_preferred_interfaces(this->host_.in(), csv, preferred);
  CORBA::ULong count = static_cast<CORBA::ULong> (preferred.size());
  size_t i = 0;
  while (i < count && ACE_OS::strstr (preferred[i].c_str(), "if=") != 0)
    {
      // For now we disregard these with IIOP
      ++i;
    }
  if (i < count)
  {
    this->is_encodable_ = true;
    this->preferred_path_.host = CORBA::string_dup(preferred[i].c_str());
    TAO_IIOP_Endpoint* ep = this;
    for (++i; i < count; ++i)
    {
      if (ACE_OS::strstr (preferred[i].c_str(), "if=") == 0)
        ep = add_local_endpoint (ep, preferred[i].c_str(), profile);
    }

    // If we're not enforcing the preferred interfaces, then we can just add
    // a new non-preferred endpoint to the end with a default local addr.
    if (! enforce)
    {
      ep = add_local_endpoint (ep, "", profile);
    }
    else
    {
      --count;
    }
  }
  return count;
}
Exemple #9
0
CORBA::ULong
TAO_UIPMC_Endpoint::preferred_interfaces (TAO_ORB_Core *oc)
{
  ACE_Vector<ACE_CString> preferred;
  TAO_IIOP_Endpoint::find_preferred_interfaces(this->host_.in(),
                                               oc->orb_params ()->preferred_interfaces (),
                                               preferred);

  TAO_UIPMC_Endpoint *latest = this;
  CORBA::ULong count = static_cast<CORBA::ULong> (preferred.size());
  CORBA::ULong i = 0;

  while (i < count)
    {
#if defined (ACE_HAS_IPV6)
      if (ACE_OS::strstr (preferred[i].c_str(), "if=") != 0
            && this->object_addr_.get_type () == AF_INET6)
        {
          latest->preferred_if_ = CORBA::string_dup (preferred[i].c_str() + 3);
          latest->preferred_path_.host = (const char *) 0;
          if (TAO_debug_level > 3)
            ORBSVCS_DEBUG ((LM_DEBUG,
                      "TAO (%P|%t) - TAO_UIPMC_Endpoint::preferred_interfaces, setting network interface name <%s>"
                      " as preferred path for [%s] \n",
                      latest->preferred_if_.in(), this->host_.in ()));
        }
      else
#endif /* ACE_HAS_IPV6 */
        {
          latest->preferred_path_.host =
            CORBA::string_dup (preferred[i].c_str());

          if (TAO_debug_level > 3)
            ORBSVCS_DEBUG ((LM_DEBUG,
                      "TAO (%P|%t) - TAO_UIPMC_Endpoint::preferred_interfaces, adding path [%s]"
                      " as preferred local address for [%s] \n",
                      latest->preferred_path_.host.in(), this->host_.in ()));
        }

      ++i;
      if (i < count)
        {
          TAO_Endpoint *tmp_ep =
            latest->duplicate ();
          latest->next_ = dynamic_cast<TAO_UIPMC_Endpoint *> (tmp_ep);
          if (!latest->next_)
            {
              delete tmp_ep;
              return i;
            }

          latest = latest->next_;
        }
    }

  if (count > 0 &&
      !oc->orb_params ()->enforce_pref_interfaces ())
    {
      TAO_Endpoint *tmp_ep = latest->duplicate ();
      latest->next_ =
        dynamic_cast<TAO_UIPMC_Endpoint *> (tmp_ep);
      if (!latest->next_)
        {
          delete tmp_ep;
          return count;
        }

      latest->next_->preferred_path_.host = static_cast<const char *> (0);
      ++count;
    }

  return count;
}
Exemple #10
0
void TAO::PG_FactoryRegistry::unregister_factory_by_location (
    const PortableGroup::Location & location)
{
  METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory_by_location);

  ////////////////////////////////////////////
  // a vector of roles that need to be deleted.
  ACE_Vector<ACE_CString> emptyRoles;

  // iterate through the registery
  for (RegistryType_Iterator it = this->registry_.begin();
       it != this->registry_.end();
       ++it)
  {
    RegistryType_Entry & entry = *it;
    ACE_CString & role = entry.ext_id_;
    RoleInfo * role_info =  entry.int_id_;

    PortableGroup::FactoryInfos & infos = role_info->infos_;
    // ORBSVCS_ERROR((LM_INFO,  "unregister_factory_by_location: Checking role %s\n", role.c_str()  ));

    int found = 0;
    CORBA::ULong length = infos.length();
    for (CORBA::ULong nInfo = 0u; !found && nInfo < length; ++nInfo)
    {
      PortableGroup::FactoryInfo & info = infos[nInfo];
      if (info.the_location == location)
      {

        ORBSVCS_ERROR((LM_INFO,
          "%s: Unregister_factory_by_location: Removing: [%d] %s@%s\n",
          this->identity_.c_str(),
          static_cast<int> (nInfo),
          role.c_str(),
          static_cast<const char *> (location[0].id)
          ));
        found = 1;
        if (length > 1)
        {
          while (nInfo + 1 < length)
          {
            ORBSVCS_ERROR((LM_INFO,
              "%s: Unregister_factory_by_location: Move: [%d] %s to [%d]\n",
              this->identity_.c_str(),
              (int)nInfo + 1, role.c_str(), (int)nInfo
              ));
            infos[nInfo] = infos[nInfo + 1];
            nInfo += 1;
          }
          ORBSVCS_ERROR((LM_INFO,
            "%s: unregister_factory_by_location: New length [%d] %s\n",
            this->identity_.c_str(),
            (int)nInfo, role.c_str()
            ));
          infos.length(nInfo);
        }
        else
        {
          ORBSVCS_ERROR((LM_INFO,
            "%s: Removed all entries for %s\n",
            this->identity_.c_str(),
            role.c_str()
            ));
          ACE_ASSERT ( length == 1 );
          // remember entries to be deleted
          emptyRoles.push_back(entry.ext_id_);
        }
      }
    }
  }

  // now remove any roles that became empty

  for (size_t nRole = 0; nRole < emptyRoles.size(); ++nRole)
  {
    ORBSVCS_ERROR((LM_INFO,
      "%s: Remove role %s\n",
      this->identity_.c_str(),
      emptyRoles[nRole].c_str()
      ));
    RoleInfo * role_info;
    if (this->registry_.unbind(emptyRoles[nRole], role_info) == 0)
    {
      delete role_info;
    }
    else
    {
      ORBSVCS_ERROR ((LM_ERROR,
        "%s: LOGIC ERROR AT " __FILE__ " (%d): Role to be deleted disappeared\n",
        this->identity_.c_str(),
        __LINE__));
    }
  }
  //////////////////////////
  // If all types are gone...
  if (registry_.current_size() == 0 && quit_state_ == LIVE)
  {
    ORBSVCS_ERROR(( LM_INFO,
      "%s is idle\n",
      identity()
      ));
    if (quit_on_idle_)
    {
        this->poa_->deactivate_object (this->object_id_.in ());
        quit_state_ = DEACTIVATED;
    }
  }

  METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory_by_location);
}