|
hydrogen 1.2.6
|
Object handling the communication between the core of Hydrogen and its GUI. More...
#include <EventQueue.h>
Data Structures | |
| struct | AddMidiNoteVector |
Public Member Functions | |
| ~EventQueue () | |
| bool | getSilent () const |
| Event | pop_event () |
| Reads out the next event of the EventQueue. | |
| void | push_event (const EventType type, const int nValue) |
| Queues the next event into the EventQueue. | |
| void | setSilent (bool bSilent) |
Public Member Functions inherited from Object< EventQueue > | |
| Object () | |
| Object (const Object< EventQueue > &other) | |
Public Member Functions inherited from Base | |
| Base () | |
| Base (const Base &other) | |
| virtual const char * | class_name () const |
| void | logBacktrace () const |
| Print the current stack at point into the debug log. | |
| void | Print (bool bShort=true) const |
| Prints content of toQString() via DEBUGLOG. | |
| virtual QString | toQString (const QString &sPrefix="", bool bShort=true) const |
| Formatted string version for debugging purposes. | |
Static Public Member Functions | |
| static void | create_instance () |
| If __instance equals 0, a new EventQueue singleton will be created and stored in it. | |
| static EventQueue * | get_instance () |
| Returns a pointer to the current EventQueue singleton stored in __instance. | |
Static Public Member Functions inherited from Base | |
| static const char * | _class_name () |
| return the class name | |
| static QString | base_clock (const QString &sMsg) |
| Measures the current time and stores it in __last_clock. | |
| static QString | base_clock_in (const QString &sMsg) |
| static int | bootstrap (Logger *logger, bool count=false) |
| must be called before any Object instantiation ! | |
| static bool | count_active () |
| static int | getAliveObjectCount () |
| static object_map_t | getObjectMap () |
| static Logger * | logger () |
| return the logger instance | |
| static int | objects_count () |
| static void | printObjectMapDiff (object_map_t map) |
| Creates the difference between a snapshot of the object map and its current state and prints it to std::cout. | |
| static void | set_count (bool flag) |
| enable/disable class instances counting | |
| static void | write_objects_map_to (std::ostream &out, object_map_t *map=nullptr) |
| output the full objects map to a given ostream | |
| static void | write_objects_map_to_cerr () |
| output objects map to stderr | |
Data Fields | |
| std::vector< AddMidiNoteVector > | m_addMidiNoteVector |
Private Member Functions | |
| EventQueue () | |
| Constructor of the EventQueue class. | |
Private Attributes | |
| Event | __events_buffer [MAX_EVENTS] |
| Array of all events contained in the EventQueue. | |
| volatile unsigned int | __read_index |
| Continuously growing number indexing the event, which has been read from the EventQueue most recently. | |
| volatile unsigned int | __write_index |
| Continuously growing number indexing the event, which has been written to the EventQueue most recently. | |
| bool | m_bSilent |
| Whether or not to push log messages. | |
| std::mutex | m_mutex |
| Mutex to lock access to queue. | |
Static Private Attributes | |
| static EventQueue * | __instance = nullptr |
| Object holding the current EventQueue singleton. | |
Additional Inherited Members | |
Static Public Attributes inherited from Base | |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. | |
Protected Member Functions inherited from Object< EventQueue > | |
| ~Object () | |
Protected Member Functions inherited from Base | |
| ~Base () | |
Static Protected Member Functions inherited from Base | |
| static void | registerClass (const char *name, const atomic_obj_cpt_t *counters) |
Static Protected Attributes inherited from Base | |
| static bool | __count = false |
| should we count class instances | |
| static timeval | __last_clock = { 0, 0 } |
| static Logger * | __logger = nullptr |
| static bool | bLogColors = true |
Object handling the communication between the core of Hydrogen and its GUI.
Whenever a specific condition is met or occasion happens within the core part of Hydrogen (its engine), an Event will be added to the EventQueue singleton. The GUI checks the content of this queue on a regular basis using HydrogenApp::onEventQueueTimer(). The actual frequency is set in the constructor HydrogenApp::HydrogenApp() to 20 times per second. Now, whenever an Event of a certain EventType is encountered, the corresponding function in the EventListener will be invoked to respond to the condition of the engine. For details about the mapping of EventTypes to functions please see the documentation of HydrogenApp::onEventQueueTimer().
Definition at line 210 of file EventQueue.h.
| ~EventQueue | ( | ) |
Definition at line 52 of file EventQueue.cpp.
|
private |
Constructor of the EventQueue class.
It fills all MAX_EVENTS slots of the __events_buffer with H2Core::EVENT_NONE and assigns itself to __instance. Called by create_instance().
Definition at line 38 of file EventQueue.cpp.
|
static |
If __instance equals 0, a new EventQueue singleton will be created and stored in it.
It is called in Hydrogen::create_instance().
Definition at line 30 of file EventQueue.cpp.
|
inlinestatic |
Returns a pointer to the current EventQueue singleton stored in __instance.
Definition at line 224 of file EventQueue.h.
|
inline |
Definition at line 326 of file EventQueue.h.
| Event pop_event | ( | ) |
Reads out the next event of the EventQueue.
Since the event read out most recently is indexed with __read_index, this variable is incremented once and its modulo with respect to MAX_EVENTS is calculated to determine the event returned from __events_buffer.
The modulo operation is necessary because __read_index will be only incremented and does not respect the actual length of __events_buffer itself.
Definition at line 88 of file EventQueue.cpp.
| void push_event | ( | const EventType | type, |
| const int | nValue ) |
Queues the next event into the EventQueue.
The event itself will be constructed inside the function and will be two properties: an EventType type and a value nValue. Since the event written to the queue most recently is indexed with __write_index, this variable is incremented once and its modulo with respect to MAX_EVENTS is calculated to determine the position of insertion into __events_buffer.
The modulo operation is necessary because __write_index will be only incremented and does not respect the actual length of __events_buffer itself.
| type | Type of the event, which will be queued. |
| nValue | Value specifying the content of the new event. |
Definition at line 58 of file EventQueue.cpp.
|
inline |
Definition at line 329 of file EventQueue.h.
|
private |
Array of all events contained in the EventQueue.
Its length is set to MAX_EVENTS and it gets initialized with H2Core::EVENT_NONE in EventQueue().
Definition at line 315 of file EventQueue.h.
|
staticprivate |
Object holding the current EventQueue singleton.
It is initialized with nullptr, set in EventQueue(), and accessed via get_instance().
Definition at line 293 of file EventQueue.h.
|
private |
Continuously growing number indexing the event, which has been read from the EventQueue most recently.
It is incremented with each call to pop_event().
Definition at line 301 of file EventQueue.h.
|
private |
Continuously growing number indexing the event, which has been written to the EventQueue most recently.
It is incremented with each call to push_event().
Definition at line 308 of file EventQueue.h.
| std::vector<AddMidiNoteVector> m_addMidiNoteVector |
Definition at line 274 of file EventQueue.h.
|
private |
Whether or not to push log messages.
Definition at line 323 of file EventQueue.h.
|
private |
Mutex to lock access to queue.
Definition at line 320 of file EventQueue.h.