glue.h 1014 B

12345678910111213141516171819202122232425262728293031
  1. typedef void (*HandlerFunctionPtr)(void *data, int stringHash, void *variantMap /* Urho3D::VariantMap& */);
  2. class NotificationProxy : public Urho3D::EventHandler {
  3. public:
  4. NotificationProxy (Urho3D::Object *receiver, HandlerFunctionPtr func, void *data, Urho3D::StringHash evtHash)
  5. : Urho3D::EventHandler(receiver, data), theFunc(func), evtHash_(evtHash) {
  6. }
  7. virtual void Invoke(Urho3D::VariantMap& eventData)
  8. {
  9. void *p = &eventData;
  10. (*theFunc)(userData_, eventType_.Value (), p);
  11. }
  12. virtual Urho3D::EventHandler* Clone() const
  13. {
  14. NotificationProxy *x = new NotificationProxy(receiver_, theFunc, userData_, evtHash_);
  15. x->SetSenderAndEventType (sender_, eventType_);
  16. return x;
  17. }
  18. void Unsub ()
  19. {
  20. receiver_->UnsubscribeFromEvent (evtHash_);
  21. // This will in turn call delete on the NotificationProxy
  22. }
  23. protected:
  24. HandlerFunctionPtr theFunc;
  25. Urho3D::StringHash evtHash_;
  26. };