Core: Added Listenable class (Made class Listener system generic)

Former-commit-id: 3baed32d6720c6455f50af51f262292ece9943fa
This commit is contained in:
Lynix
2015-05-06 18:17:18 +02:00
parent 3195a50114
commit 44ff678002
11 changed files with 121 additions and 206 deletions

View File

@@ -8,6 +8,7 @@
#define NAZARA_NODE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Listenable.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
@@ -15,17 +16,13 @@
#include <unordered_map>
#include <vector>
class NAZARA_API NzNode
class NAZARA_API NzNode : public NzListenable<NzNode>
{
public:
class Listener;
NzNode();
NzNode(const NzNode& node);
virtual ~NzNode();
void AddListener(Listener* listener, void* userdata = nullptr) const;
void EnsureDerivedUpdate() const;
void EnsureTransformMatrixUpdate() const;
@@ -56,7 +53,6 @@ class NAZARA_API NzNode
NzNode& Move(const NzVector3f& movement, nzCoordSys coordSys = nzCoordSys_Local);
NzNode& Move(float movementX, float movementY, float movementZ = 0.f, nzCoordSys coordSys = nzCoordSys_Local);
void RemoveListener(Listener* listener) const;
NzNode& Rotate(const NzQuaternionf& rotation, nzCoordSys coordSys = nzCoordSys_Local);
NzNode& Scale(const NzVector3f& scale);
@@ -131,14 +127,6 @@ class NAZARA_API NzNode
bool m_inheritScale;
mutable bool m_transformMatrixUpdated;
private:
void NotifyInvalidation();
void NotifyParented(const NzNode* parent);
private:
mutable std::unordered_map<Listener*, void*> m_listeners;
bool m_listenersLocked;
};
#endif // NAZARA_NODE_HPP