leocad/common/message.cpp

33 lines
541 B
C++
Raw Normal View History

2011-09-07 23:06:51 +02:00
//
// 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);
}