equal
deleted
inserted
replaced
|
1 /* |
|
2 * $Id: readerthread.cpp 54 2008-01-10 00:24:52Z mbroeker $ |
|
3 * $URL: http://localhost/svn/cpp/qMonitor/trunk/readerthread.cpp $ |
|
4 */ |
|
5 |
|
6 #include "include/readerthread.h" |
|
7 #include <exception> |
|
8 |
|
9 readerThread::readerThread (Monitor * parent) |
|
10 { |
|
11 handle = parent; |
|
12 } |
|
13 |
|
14 void readerThread::run () |
|
15 { |
|
16 std::string s; |
|
17 DataChangeEvent *dce; |
|
18 |
|
19 try { |
|
20 PacketParser reader (-1); |
|
21 |
|
22 for (;;) { |
|
23 while (reader.dataAvailable ()) { |
|
24 reader.setProtocol (handle->getProtocol ()); |
|
25 reader.setPort (handle->getPort ()); |
|
26 |
|
27 s = reader.read (); |
|
28 |
|
29 if (s != "") { |
|
30 dce = new DataChangeEvent (s.c_str ()); |
|
31 QApplication::postEvent ((QObject *) handle, (QEvent *) dce); |
|
32 } |
|
33 } |
|
34 } |
|
35 } |
|
36 catch (std::exception const &e) { |
|
37 dce = new DataChangeEvent (e.what ()); |
|
38 QApplication::postEvent ((QObject *) handle, (QEvent *) dce); |
|
39 std::cerr << e.what () << std::endl; |
|
40 } |
|
41 } |