예제 #1
0
void object::test<3>()
{
    Keyed one("one"), two("two"), three("three");
    // We don't want to rely on the underlying container delivering keys
    // in any particular order. That allows us the flexibility to
    // reimplement LLInstanceTracker using, say, a hash map instead of a
    // std::map. We DO insist that every key appear exactly once.
    typedef std::vector<std::string> StringVector;
    StringVector keys(Keyed::beginKeys(), Keyed::endKeys());
    std::sort(keys.begin(), keys.end());
    StringVector::const_iterator ki(keys.begin());
    ensure_equals(*ki++, "one");
    ensure_equals(*ki++, "three");
    ensure_equals(*ki++, "two");
    // Use ensure() here because ensure_equals would want to display
    // mismatched values, and frankly that wouldn't help much.
    ensure("didn't reach end", ki == keys.end());

    // Use a somewhat different approach to order independence with
    // beginInstances(): explicitly capture the instances we know in a
    // set, and delete them as we iterate through.
    typedef std::set<Keyed*> InstanceSet;
    InstanceSet instances;
    instances.insert(&one);
    instances.insert(&two);
    instances.insert(&three);
    for (Keyed::instance_iter ii(Keyed::beginInstances()), iend(Keyed::endInstances());
            ii != iend; ++ii)
    {
        Keyed& ref = *ii;
        ensure_equals("spurious instance", instances.erase(&ref), 1);
    }
    ensure_equals("unreported instance", instances.size(), 0);
}
예제 #2
0
		scene::Instance* erase (scene::Instantiable::Observer* observer, const scene::Path& path)
		{
			return m_instances.erase(observer, path);
		}
예제 #3
0
		void insert (scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
		{
			m_instances.insert(observer, path, instance);
		}
예제 #4
0
		void forEachInstance (const scene::Instantiable::Visitor& visitor)
		{
			m_instances.forEachInstance(visitor);
		}
예제 #5
0
파일: group.cpp 프로젝트: chrisglass/ufoai
		void eraseChild (scene::Node& child)
		{
			m_instances.eraseChild(child);
		}
예제 #6
0
파일: group.cpp 프로젝트: chrisglass/ufoai
		void insertChild (scene::Node& child)
		{
			m_instances.insertChild(child);
		}