mirror of
https://github.com/leozide/leocad
synced 2024-11-17 07:47:55 +01:00
33 lines
541 B
C++
33 lines
541 B
C++
|
//
|
||
|
// LeoCAD messaging system
|
||
|
//
|
||
|
|
||
|
#include "message.h"
|
||
|
|
||
|
Messenger::Messenger ()
|
||
|
{
|
||
|
m_nRef = 0;
|
||
|
}
|
||
|
|
||
|
Messenger::~Messenger ()
|
||
|
{
|
||
|
for (int i = 0; i < m_Listeners.GetSize (); i++)
|
||
|
delete m_Listeners[i];
|
||
|
}
|
||
|
|
||
|
void Messenger::Dispatch (int message, void *data)
|
||
|
{
|
||
|
for (int i = 0; i < m_Listeners.GetSize (); i++)
|
||
|
m_Listeners[i]->func (message, data, m_Listeners[i]->user);
|
||
|
}
|
||
|
|
||
|
void Messenger::Listen (LC_MSG_CALLBACK func, void *user)
|
||
|
{
|
||
|
LC_MSG_STRUCT *s = new LC_MSG_STRUCT;
|
||
|
|
||
|
s->func = func;
|
||
|
s->user = user;
|
||
|
|
||
|
m_Listeners.Add (s);
|
||
|
}
|