#include <vector>
#include "string/string.h"
-#include "generic/callback.h"
+#include "signal/signal.h"
#include "scenelib.h"
#include "instancelib.h"
#include "treemodel.h"
InstanceMap m_instances;
scene::Instantiable::Observer* m_observer;
- typedef std::set<Callback> BoundsChangedCallbacks;
- BoundsChangedCallbacks m_boundsChanged;
+ Signal0 m_boundsChanged;
scene::Path m_rootpath;
- std::vector<Callback> m_sceneChangedCallbacks;
+ Signal0 m_sceneChangedCallbacks;
TypeIdMap<NODETYPEID_MAX> m_nodeTypeIds;
TypeIdMap<INSTANCETYPEID_MAX> m_instanceTypeIds;
{
}
- void addSceneChangedCallback(const Callback& callback)
+ void addSceneChangedCallback(const SignalHandler& handler)
{
- m_sceneChangedCallbacks.push_back(callback);
+ m_sceneChangedCallbacks.connectLast(handler);
}
void sceneChanged()
{
- std::for_each(m_sceneChangedCallbacks.begin(), m_sceneChangedCallbacks.end(), CallbackInvoke());
+ m_sceneChangedCallbacks();
}
scene::Node& root()
{
ASSERT_MESSAGE(!m_rootpath.empty(), "scenegraph root does not exist");
- return *m_rootpath.top();
+ return m_rootpath.top();
}
void insert_root(scene::Node& root)
{
ASSERT_MESSAGE(!m_rootpath.empty(), "scenegraph root does not exist");
- scene::Node& root = *m_rootpath.top();
+ scene::Node& root = m_rootpath.top();
m_rootpath.pop();
}
void boundsChanged()
{
- std::for_each(m_boundsChanged.begin(), m_boundsChanged.end(), CallbackInvoke());
+ m_boundsChanged();
}
void traverse(const Walker& walker)
m_instances.erase(PathConstReference(instance->path()));
}
- void addBoundsChangedCallback(const Callback& boundsChanged)
+ SignalHandlerId addBoundsChangedCallback(const SignalHandler& boundsChanged)
{
- ASSERT_MESSAGE(m_boundsChanged.find(boundsChanged) == m_boundsChanged.end(), "bounds-changed callback already registered");
- m_boundsChanged.insert(boundsChanged);
+ return m_boundsChanged.connectLast(boundsChanged);
}
- void removeBoundsChangedCallback(const Callback& boundsChanged)
+ void removeBoundsChangedCallback(SignalHandlerId id)
{
- ASSERT_MESSAGE(m_boundsChanged.find(boundsChanged) != m_boundsChanged.end(), "bounds-changed callback not registered");
- m_boundsChanged.erase(boundsChanged);
+ m_boundsChanged.disconnect(id);
}
TypeId getNodeTypeId(const char* name)