- typedef InstanceMap::iterator iterator;
-
- iterator begin()
- {
- return m_instances.begin();
- }
- iterator end()
- {
- return m_instances.end();
- }
-
- // traverse observer
- void insert(scene::Node& child)
- {
- for(iterator i = begin(); i != end(); ++i)
- {
- Node_traverseSubgraph(child, InstanceSubgraphWalker((*i).first.first, (*i).first.second, (*i).second));
- (*i).second->boundsChanged();
- }
- }
- void erase(scene::Node& child)
- {
- for(iterator i = begin(); i != end(); ++i)
- {
- Node_traverseSubgraph(child, UninstanceSubgraphWalker((*i).first.first, (*i).first.second));
- (*i).second->boundsChanged();
- }
- }
-
- // instance
- void forEachInstance(const scene::Instantiable::Visitor& visitor)
- {
- for(iterator i = begin(); i != end(); ++i)
- {
- visitor.visit(*(*i).second);
- }
- }
-
- void insert(scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
- {
- ASSERT_MESSAGE(m_instances.find(key_type(observer, PathConstReference(instance->path()))) == m_instances.end(), "InstanceSet::insert - element already exists");
- m_instances.insert(InstanceMap::value_type(key_type(observer, PathConstReference(instance->path())), instance));
- }
- scene::Instance* erase(scene::Instantiable::Observer* observer, const scene::Path& path)
- {
- ASSERT_MESSAGE(m_instances.find(key_type(observer, PathConstReference(path))) != m_instances.end(), "InstanceSet::erase - failed to find element");
- InstanceMap::iterator i = m_instances.find(key_type(observer, PathConstReference(path)));
- scene::Instance* instance = i->second;
- m_instances.erase(i);
- return instance;
- }
-
- void transformChanged()
- {
- for(InstanceMap::iterator i = m_instances.begin(); i != m_instances.end(); ++i)
- {
- (*i).second->transformChanged();
- }
- }
- typedef MemberCaller<InstanceSet, &InstanceSet::transformChanged> TransformChangedCaller;
- void boundsChanged()
- {
- for(InstanceMap::iterator i = m_instances.begin(); i != m_instances.end(); ++i)
- {
- (*i).second->boundsChanged();
- }
- }
- typedef MemberCaller<InstanceSet, &InstanceSet::boundsChanged> BoundsChangedCaller;
-};