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