C++ API Reference RNBO: src/RNBO_StartupEvent.h Source File

RNBO: src/RNBO_StartupEvent.h Source File

1 //
2 // RNBO_StartupEvent.h
3 //
4 //
5 
6 #ifndef _RNBO_StartupEvent_H_
7 #define _RNBO_StartupEvent_H_
8 
9 #include <memory>
10 
11 #include "RNBO_Debug.h"
12 #include "RNBO_Types.h"
13 #include "RNBO_List.h"
14 #include "RNBO_Presets.h"
15 
16 namespace RNBO {
17 
18  class PatcherEventTarget;
19 
23  class StartupEvent {
24 
25  public:
26 
27  enum Type {
28  Invalid = -1,
29  Begin = 0,
30  End,
31  Max_Type
32  };
33 
34 
35  StartupEvent()
36  : _eventTime(0)
37  , _type(Invalid)
38  {
39  }
40 
41  ~StartupEvent()
42  {
43  }
44 
45  StartupEvent(MillisecondTime eventTime, StartupEvent::Type type)
46  : _eventTime(eventTime)
47  , _type(type)
48  {
49  }
50 
51  StartupEvent(const StartupEvent& other)
52  : _eventTime(other._eventTime)
53  {
54  _type = other._type;
55  }
56 
57  StartupEvent(StartupEvent&& other)
58  : _eventTime(other._eventTime)
59  {
60  _type = other._type;
61  }
62 
63  StartupEvent& operator = (const StartupEvent& other)
64  {
65  _eventTime = other._eventTime;
66  _type = other._type;
67 
68  return *this;
69  }
70 
71  bool operator==(const StartupEvent& rhs) const
72  {
73  return rhs.getTime() == getTime()
74  && rhs.getType() == getType();
75  }
76 
77  StartupEvent::Type getType() const { return _type; }
78  MillisecondTime getTime() const { return _eventTime; }
79 
80  // we will always use the default event target (the top level patcher)
81  PatcherEventTarget* getEventTarget() const { return nullptr; }
82 
83  // debugging
84  void dumpEvent() const {
85  // disabling for now to avoid requiring fprintf support in generated code
86 // fprintf(stdout, "StartupEvent: time=%.3f type=%d", _eventTime, _type);
87  }
88 
89  protected:
90 
91  MillisecondTime _eventTime;
92  StartupEvent::Type _type = Invalid;
93 
94  friend class EventVariant;
95 
96  void setTime(MillisecondTime eventTime) { _eventTime = eventTime; }
97  };
98 
99 } // namespace RNBO
100 
101 
102 #endif // #ifndef _RNBO_StartupEvent_H_