/*
* $Id: readerthread.cpp 54 2008-01-10 00:24:52Z mbroeker $
* $URL: http://localhost/svn/cpp/qMonitor/trunk/readerthread.cpp $
*/
#include "include/readerthread.h"
#include <exception>
readerThread::readerThread (Monitor * parent)
{
handle = parent;
}
void readerThread::run ()
{
std::string s;
DataChangeEvent *dce;
try {
PacketParser reader (-1);
for (;;) {
while (reader.dataAvailable ()) {
reader.setProtocol (handle->getProtocol ());
reader.setPort (handle->getPort ());
s = reader.read ();
if (s != "") {
dce = new DataChangeEvent (s.c_str ());
QApplication::postEvent ((QObject *) handle, (QEvent *) dce);
}
}
}
} catch (std::exception const &e) {
dce = new DataChangeEvent (e.what ());
QApplication::postEvent ((QObject *) handle, (QEvent *) dce);
std::cerr << e.what () << std::endl;
}
}