Exemplo n.º 1
0
const TAO_Control_Registry::NameList&
TAO_Control_Registry::names (void)
{
  if (this->name_cache_.length () == 0)
    {
      ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX,
                              guard,
                              this->mutex_,
                              this->name_cache_);

      if (this->name_cache_.length () == 0)
        {
          CORBA::ULong length = 0;
          Map::iterator itr (this->map_);
          Map::value_type* entry = 0;

          while (itr.next (entry))
            {
              this->name_cache_.length (length + 1);
              this->name_cache_[length++] =
                        CORBA::string_dup (entry->key ().c_str ());
              itr.advance ();
            }
        }
    }

  return this->name_cache_;
}
Exemplo n.º 2
0
TAO_Control_Registry::~TAO_Control_Registry (void)
{
  ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_);

  Map::iterator itr (this->map_);
  Map::value_type* entry = 0;

  while (itr.next (entry))
    {
      delete entry->item ();
      itr.advance ();
    }
}
Exemplo n.º 3
0
    bool testBasics() {
        typedef HashMap<AString, int, StringPolicy> Map;
        Map map;

        if (!check(map.init(), "initialized"))
            return false;

        Map::Result r = map.find("cat");
        if (!check(!r.found(), "cat not found"))
            return false;

        Map::Insert i = map.findForAdd("cat");
        if (!check(!i.found(), "cat not found for add"))
            return false;
        if (!check(map.add(i, AString("cat"), 5), "cat added"))
            return false;
        if (!check(r->value == 5, "cat is 5"))
            return false;

        Map::iterator iter = map.iter();
        if (!check(iter->key.compare("cat") == 0, "iterator got key cat"))
            return false;
        if (!check(iter->value == 5, "iterator got value 5"))
            return false;
        iter.next();
        if (!check(iter.empty(), "iterator should be finished"))
            return false;

        i = map.findForAdd("cat");
        if (!check(i.found(), "cat found through insert"))
            return false;

        r = map.find("dog");
        if (!check(!r.found(), "dog not found"))
            return false;

        r = map.find("cat");
        if (!check(r.found(), "cat found"))
            return false;
        if (!check(r->value == 5, "cat is 5"))
            return false;
        map.remove(r);

        r = map.find("cat");
        if (!check(!r.found(), "cat ran away"))
            return false;

        return true;
    }