Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MessageHandler Class Reference

Class for handling and sending messages. More...

#include <messagehandler.h>

+ Collaboration diagram for MessageHandler:

Public Member Functions

 ~MessageHandler ()
 Empty desctructor. More...
 
void process ()
 Main task, processing the events in the queue. More...
 
void addListener (MessageListener *listener)
 Connect a new message listener. More...
 
void removeListener (MessageListener *listener)
 Disconnect a message listener. More...
 
void addMessage (MessagePtr message, bool dropOlder=false)
 Submit a message. More...
 

Static Public Member Functions

template<class msgclass , class... Args>
static void send (Args &&...args)
 short function for creating and sending a message More...
 
static void send (Message::MessageTypes type)
 short function for creating and sending a simple message More...
 
template<class msgclass , class... Args>
static void sendUnique (Args &&...args)
 short function for creating and sending a message and drop older messages of the same type so that this message is unique More...
 
static void sendUnique (Message::MessageTypes type)
 short function for creating and sending a simple message More...
 
static MessageHandlergetSingleton ()
 get a reference to the singleton class More...
 
static MessageHandlergetSingletonPtr ()
 get a pointer to the singleton class More...
 

Private Member Functions

 MessageHandler ()
 private constructor since this class is a singleton More...
 

Private Attributes

std::list< MessageListener * > mListeners
 List of all listeners. More...
 
std::list< MessageListener * > mListenersToAdd
 List of listeners to add in the next frame. More...
 
std::list< MessageListener * > mListenersToRemove
 List of listeners to remove in the next frame. More...
 
std::mutex mListenersChangesMutex
 Mutex for accessing the listeners list. More...
 
std::list< MessagePtrmMessages
 Queue of messages to be submitted. More...
 
std::mutex mMessageMutex
 Mutex for accessing the queue. More...
 

Static Private Attributes

static MessageHandler mSingleton
 Singleton instance. More...
 

Detailed Description

Class for handling and sending messages.

This class adds messages of the different threads, places them in a queue and sends them to the connected listeners.

This class is a singleton. Note that "process" has to be called in the same thread as the used gui.

Definition at line 43 of file messagehandler.h.

Constructor & Destructor Documentation

MessageHandler::MessageHandler ( )
private

private constructor since this class is a singleton

Definition at line 33 of file messagehandler.cpp.

MessageHandler::~MessageHandler ( )

Empty desctructor.

Definition at line 39 of file messagehandler.cpp.

Member Function Documentation

void MessageHandler::addListener ( MessageListener listener)

Connect a new message listener.

Definition at line 101 of file messagehandler.cpp.

void MessageHandler::addMessage ( MessagePtr  message,
bool  dropOlder = false 
)

Submit a message.

Parameters
messagethe message to add
dropOlderif true it will remove all older messages of the same type

Definition at line 123 of file messagehandler.cpp.

MessageHandler & MessageHandler::getSingleton ( )
static

get a reference to the singleton class

Definition at line 45 of file messagehandler.cpp.

MessageHandler * MessageHandler::getSingletonPtr ( )
static

get a pointer to the singleton class

Definition at line 51 of file messagehandler.cpp.

void MessageHandler::process ( )

Main task, processing the events in the queue.

Definition at line 57 of file messagehandler.cpp.

void MessageHandler::removeListener ( MessageListener listener)

Disconnect a message listener.

Definition at line 111 of file messagehandler.cpp.

template<class msgclass , class... Args>
static void MessageHandler::send ( Args &&...  args)
inlinestatic

short function for creating and sending a message

Definition at line 48 of file messagehandler.h.

+ Here is the call graph for this function:

static void MessageHandler::send ( Message::MessageTypes  type)
inlinestatic

short function for creating and sending a simple message

Definition at line 53 of file messagehandler.h.

template<class msgclass , class... Args>
static void MessageHandler::sendUnique ( Args &&...  args)
inlinestatic

short function for creating and sending a message and drop older messages of the same type so that this message is unique

Definition at line 57 of file messagehandler.h.

+ Here is the call graph for this function:

static void MessageHandler::sendUnique ( Message::MessageTypes  type)
inlinestatic

short function for creating and sending a simple message

Definition at line 62 of file messagehandler.h.

Member Data Documentation

std::list<MessageListener*> MessageHandler::mListeners
private

List of all listeners.

Definition at line 82 of file messagehandler.h.

std::mutex MessageHandler::mListenersChangesMutex
mutableprivate

Mutex for accessing the listeners list.

Definition at line 85 of file messagehandler.h.

std::list<MessageListener*> MessageHandler::mListenersToAdd
private

List of listeners to add in the next frame.

Definition at line 83 of file messagehandler.h.

std::list<MessageListener*> MessageHandler::mListenersToRemove
private

List of listeners to remove in the next frame.

Definition at line 84 of file messagehandler.h.

std::mutex MessageHandler::mMessageMutex
mutableprivate

Mutex for accessing the queue.

Definition at line 87 of file messagehandler.h.

std::list<MessagePtr> MessageHandler::mMessages
private

Queue of messages to be submitted.

Definition at line 86 of file messagehandler.h.

MessageHandler MessageHandler::mSingleton
staticprivate

Singleton instance.

Definition at line 81 of file messagehandler.h.


The documentation for this class was generated from the following files: