SCENE C++ API  2.0.22
lssignal.h
1 #pragma once
2 
3 #include <core_api/lsglobaldefinitions.h>
4 #include <core_api/lsinterface.h>
5 #include <core_api/lsreftype.h>
6 #include <core_api/lstrackable.h>
7 #include <core_api/lsslot.h>
8 
9 namespace SCENE_API {
10 
11 // Forward declarations
12 class LSSignalBase_Implementation;
13 template <typename T> class LSSignal_Implementation;
14 
17 class LSSignalBase : public LSInterface
18 {
19 protected:
20  LS_INTERFACE(LSSignalBase, LSInterface);
21 };
22 
29 template<class Event>
30 class LSSignal : public LSSignalBase
31 {
32 public:
33  LSSignal();
34  LSSignal(const LSSignal& signal);
35  LSSignal& operator=(const LSSignal&);
36  virtual ~LSSignal();
37 
44  void connect( void(*handler)(Event))
45  {
46  connect(new LSSlot<Event>(handler));
47  }
48 
58  template<class Trackable>
59  void connect(Trackable* trackable, void(Trackable::*handler)(Event))
60  {
61  connect(new LSSlot<Event, Trackable>(trackable, handler));
62  }
63 
70  void operator()(Event event, bool synchronize = false);
71 
72 protected:
73  void connect(ref_ptr<LSSlotBase<Event> > slot);
74 
75 private:
76  LS_INTERFACE_TEMPLATE(LSSignal, Event, LSSignalBase);
77 };
78 
79 }