author | Markus Bröker <mbroeker@largo.homelinux.org> |
Tue, 02 Feb 2010 13:26:30 +0100 | |
changeset 8 | 6097dc1fe2cf |
parent 4 | fdf04a93faeb |
permissions | -rw-r--r-- |
0
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
1 |
/* |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
2 |
* $Id: readerthread.cpp 54 2008-01-10 00:24:52Z mbroeker $ |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
3 |
* $URL: http://localhost/svn/cpp/qMonitor/trunk/readerthread.cpp $ |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
4 |
*/ |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
5 |
|
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
6 |
#include "include/readerthread.h" |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
7 |
#include <exception> |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
8 |
|
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
9 |
readerThread::readerThread (Monitor * parent) |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
10 |
{ |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
11 |
handle = parent; |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
12 |
} |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
13 |
|
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
14 |
void readerThread::run () |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
15 |
{ |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
16 |
std::string s; |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
17 |
DataChangeEvent *dce; |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
18 |
|
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
19 |
try { |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
20 |
PacketParser reader (-1); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
21 |
|
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
22 |
for (;;) { |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
23 |
while (reader.dataAvailable ()) { |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
24 |
reader.setProtocol (handle->getProtocol ()); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
25 |
reader.setPort (handle->getPort ()); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
26 |
|
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
27 |
s = reader.read (); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
28 |
|
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
29 |
if (s != "") { |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
30 |
dce = new DataChangeEvent (s.c_str ()); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
31 |
QApplication::postEvent ((QObject *) handle, (QEvent *) dce); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
32 |
} |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
33 |
} |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
34 |
} |
4
fdf04a93faeb
Codebase indented by me and gnu-indent
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
0
diff
changeset
|
35 |
} catch (std::exception const &e) { |
0
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
36 |
dce = new DataChangeEvent (e.what ()); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
37 |
QApplication::postEvent ((QObject *) handle, (QEvent *) dce); |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
38 |
std::cerr << e.what () << std::endl; |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
39 |
} |
826dd5531eb0
svn copy of qmonitor
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
40 |
} |