- CompiledGraph(scene::Instantiable::Observer* observer)
- : m_observer(observer)
- {
- }
-
- void addSceneChangedCallback(const SignalHandler& handler)
- {
- m_sceneChangedCallbacks.connectLast(handler);
- }
- void sceneChanged()
- {
- m_sceneChangedCallbacks();
- }
-
- scene::Node& root()
- {
- ASSERT_MESSAGE(!m_rootpath.empty(), "scenegraph root does not exist");
- return *m_rootpath.top();
- }
- void insert_root(scene::Node& root)
- {
- //globalOutputStream() << "insert_root\n";
-
- ASSERT_MESSAGE(m_rootpath.empty(), "scenegraph root already exists");
-
- root.IncRef();
-
- Node_traverseSubgraph(root, InstanceSubgraphWalker(this, scene::Path(), 0));
-
- m_rootpath.push(makeReference(root));
- }
- void erase_root()
- {
- //globalOutputStream() << "erase_root\n";
-
- ASSERT_MESSAGE(!m_rootpath.empty(), "scenegraph root does not exist");
-
- scene::Node& root = *m_rootpath.top();
-
- m_rootpath.pop();
-
- Node_traverseSubgraph(root, UninstanceSubgraphWalker(this, scene::Path()));
-
- root.DecRef();
- }
- void boundsChanged()
- {
- m_boundsChanged();
- }
-
- void traverse(const Walker& walker)
- {
- traverse_subgraph(walker, m_instances.begin());
- }
-
- void traverse_subgraph(const Walker& walker, const scene::Path& start)
- {
- if(!m_instances.empty())
- {
- traverse_subgraph(walker, m_instances.find(PathConstReference(start)));
- }
- }
-
- scene::Instance* find(const scene::Path& path)
- {
- InstanceMap::iterator i = m_instances.find(PathConstReference(path));
- if(i == m_instances.end())
- {
- return 0;
- }
- return (*i).second;
- }
-
- void insert(scene::Instance* instance)
- {
- m_instances.insert(InstanceMap::value_type(PathConstReference(instance->path()), instance));
-
- m_observer->insert(instance);
- }
- void erase(scene::Instance* instance)
- {
- m_observer->erase(instance);
-
- m_instances.erase(PathConstReference(instance->path()));
- }
-
- SignalHandlerId addBoundsChangedCallback(const SignalHandler& boundsChanged)
- {
- return m_boundsChanged.connectLast(boundsChanged);
- }
- void removeBoundsChangedCallback(SignalHandlerId id)
- {
- m_boundsChanged.disconnect(id);
- }
-
- TypeId getNodeTypeId(const char* name)
- {
- return m_nodeTypeIds.getTypeId(name);
- }
-
- TypeId getInstanceTypeId(const char* name)
- {
- return m_instanceTypeIds.getTypeId(name);
- }
+CompiledGraph( scene::Instantiable::Observer* observer )
+ : m_observer( observer ){
+}
+
+void addSceneChangedCallback( const SignalHandler& handler ){
+ m_sceneChangedCallbacks.connectLast( handler );
+}
+void sceneChanged(){
+ m_sceneChangedCallbacks();
+}
+
+scene::Node& root(){
+ ASSERT_MESSAGE( !m_rootpath.empty(), "scenegraph root does not exist" );
+ return m_rootpath.top();
+}
+void insert_root( scene::Node& root ){
+ //globalOutputStream() << "insert_root\n";
+
+ ASSERT_MESSAGE( m_rootpath.empty(), "scenegraph root already exists" );
+
+ root.IncRef();
+
+ Node_traverseSubgraph( root, InstanceSubgraphWalker( this, scene::Path(), 0 ) );
+
+ m_rootpath.push( makeReference( root ) );
+}
+void erase_root(){
+ //globalOutputStream() << "erase_root\n";
+
+ ASSERT_MESSAGE( !m_rootpath.empty(), "scenegraph root does not exist" );
+
+ scene::Node& root = m_rootpath.top();
+
+ m_rootpath.pop();
+
+ Node_traverseSubgraph( root, UninstanceSubgraphWalker( this, scene::Path() ) );
+
+ root.DecRef();
+}
+void boundsChanged(){
+ m_boundsChanged();
+}
+
+void traverse( const Walker& walker ){
+ traverse_subgraph( walker, m_instances.begin() );
+}
+
+void traverse_subgraph( const Walker& walker, const scene::Path& start ){
+ if ( !m_instances.empty() ) {
+ traverse_subgraph( walker, m_instances.find( PathConstReference( start ) ) );
+ }
+}
+
+scene::Instance* find( const scene::Path& path ){
+ InstanceMap::iterator i = m_instances.find( PathConstReference( path ) );
+ if ( i == m_instances.end() ) {
+ return 0;
+ }
+ return ( *i ).second;
+}
+
+void insert( scene::Instance* instance ){
+ m_instances.insert( InstanceMap::value_type( PathConstReference( instance->path() ), instance ) );
+
+ m_observer->insert( instance );
+}
+void erase( scene::Instance* instance ){
+ m_observer->erase( instance );
+
+ m_instances.erase( PathConstReference( instance->path() ) );
+}
+
+SignalHandlerId addBoundsChangedCallback( const SignalHandler& boundsChanged ){
+ return m_boundsChanged.connectLast( boundsChanged );
+}
+void removeBoundsChangedCallback( SignalHandlerId id ){
+ m_boundsChanged.disconnect( id );
+}
+
+TypeId getNodeTypeId( const char* name ){
+ return m_nodeTypeIds.getTypeId( name );
+}
+
+TypeId getInstanceTypeId( const char* name ){
+ return m_instanceTypeIds.getTypeId( name );
+}