CuteLogger
Fast and simple logging solution for Qt based applications
mvcpthread.h
1 /*
2  * Copyright (c) 2012-2013 Meltytech, LLC
3  * Author: Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef MVCPTHREAD_H
20 #define MVCPTHREAD_H
21 
22 #include <QThread>
23 #include <QMutex>
24 #include <QWaitCondition>
25 #include <QStringList>
26 #include <mvcp.h>
27 
28 class MvcpThread : public QThread
29 {
30  Q_OBJECT
31 public:
32  explicit MvcpThread(const QString& address, quint16 port, QObject *parent = 0);
33  ~MvcpThread();
34  void run();
35  void uls();
36  void cls(QString path, QObject *parent);
37  void usta(quint8 unit);
38 
39 signals:
40  void ulsResult(QStringList); // list of unit names
41  void clsResult(QObject* parent, QObjectList* children); // each object has name, full, dir, and size properties
42  void ustaResult(QObject*); // properties named same as mcvp_status
43 
44 private:
45  QString m_address;
46  quint16 m_port;
47  bool m_quit;
48  QMutex m_mutex;
49  QWaitCondition m_cond;
50  int m_command;
51  QObjectList m_commands;
52 
53  enum commands {
54  COMMAND_INVALID,
55  COMMAND_ULS,
56  COMMAND_CLS,
57  COMMAND_USTA,
58  };
59 
60  void do_uls(mvcp, QObject*);
61  void do_cls(mvcp, QObject*);
62  void do_usta(mvcp, QObject*);
63 };
64 
65 #endif // MVCPTHREAD_H
Definition: mvcp.h:84