- typedef LazyStatic<TypeCasts> StaticTypeCasts;
-
- scene::Traversable& get(NullType<scene::Traversable>)
- {
- return m_traverse;
- }
- TransformNode& get(NullType<TransformNode>)
- {
- return m_transform;
- }
- Nameable& get(NullType<Nameable>)
- {
- return m_name;
- }
- MapFile& get(NullType<MapFile>)
- {
- return m_changeTracker;
- }
-
- MapRoot(const char* name) : m_node(this, this, StaticTypeCasts::instance().get()), m_name(name)
- {
- m_node.m_isRoot = true;
-
- m_traverse.attach(this);
-
- GlobalUndoSystem().trackerAttach(m_changeTracker);
- }
- ~MapRoot()
- {
- }
- void release()
- {
- GlobalUndoSystem().trackerDetach(m_changeTracker);
-
- m_traverse.detach(this);
- delete this;
- }
- scene::Node& node()
- {
- return m_node;
- }
-
- InstanceCounter m_instanceCounter;
- void instanceAttach(const scene::Path& path)
- {
- if(++m_instanceCounter.m_count == 1)
- {
- m_traverse.instanceAttach(path_find_mapfile(path.begin(), path.end()));
- }
- }
- void instanceDetach(const scene::Path& path)
- {
- if(--m_instanceCounter.m_count == 0)
- {
- m_traverse.instanceDetach(path_find_mapfile(path.begin(), path.end()));
- }
- }
-
- void insert(scene::Node& child)
- {
- m_instances.insert(child);
- }
- void erase(scene::Node& child)
- {
- m_instances.erase(child);
- }
-
- scene::Node& clone() const
- {
- return (new MapRoot(*this))->node();
- }
-
- scene::Instance* create(const scene::Path& path, scene::Instance* parent)
- {
- return new Instance(path, parent);
- }
- void forEachInstance(const scene::Instantiable::Visitor& visitor)
- {
- m_instances.forEachInstance(visitor);
- }
- void insert(scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
- {
- m_instances.insert(observer, path, instance);
- instanceAttach(path);
- }
- scene::Instance* erase(scene::Instantiable::Observer* observer, const scene::Path& path)
- {
- instanceDetach(path);
- return m_instances.erase(observer, path);
- }
+TypeCasts(){
+ NodeStaticCast<MapRoot, scene::Instantiable>::install( m_casts );
+ NodeContainedCast<MapRoot, scene::Traversable>::install( m_casts );
+ NodeContainedCast<MapRoot, TransformNode>::install( m_casts );
+ NodeContainedCast<MapRoot, Nameable>::install( m_casts );
+ NodeContainedCast<MapRoot, MapFile>::install( m_casts );
+}
+NodeTypeCastTable& get(){
+ return m_casts;
+}