-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqmf-thread.h
More file actions
112 lines (91 loc) · 3 KB
/
qmf-thread.h
File metadata and controls
112 lines (91 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef _qe_qmf_thread_h
#define _qe_qmf_thread_h
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QLineEdit>
#include <QStringList>
#include <QModelIndex>
#include <QEvent>
#include <qpid/messaging/Connection.h>
#include <qmf/ConsoleSession.h>
#include <qmf/ConsoleEvent.h>
#include "qpid/types/Variant.h"
#include <qmf/Data.h>
#include <sstream>
#include <deque>
static QModelIndex defaultIndex;
Q_DECLARE_METATYPE(qmf::ConsoleEvent);
class QmfThread : public QThread {
Q_OBJECT
public:
QmfThread(QObject* parent);
void cancel();
void queryBroker(const std::string& qmf_class, QObject* object);
void queryObject(const qmf::DataAddr& dataAddr, QObject* object);
public slots:
void connect_localhost();
void disconnect();
void connect_url(const QString&, const QString&, const QString&);
signals:
void connectionStatusChanged(const QString&);
void isConnected(bool);
void addExchange(const qmf::Data&, uint);
void doneAddingExchanges(uint);
void qmfError(const QString&);
void receivedResponse(QObject *target, const qmf::ConsoleEvent& event, bool all);
void qmfTimer();
protected:
void run();
private:
struct Command {
bool connect;
std::string url;
std::string conn_options;
std::string qmf_options;
Command(bool _c, const std::string& _u, const std::string& _co, const std::string& _qo) :
connect(_c), url(_u), conn_options(_co), qmf_options(_qo) {}
};
typedef std::deque<Command> command_queue_t;
mutable QMutex lock;
QWaitCondition cond;
qpid::messaging::Connection conn;
qmf::ConsoleSession sess;
bool cancelled;
bool connected;
bool disconnecting;
bool pausedRefreshes;
command_queue_t command_queue;
// support for async queries
struct Query {
uint32_t correlator;
QObject* object;
bool all;
Query(QObject* _o, bool _b) : correlator(0),
object(_o), all(_b) {}
};
typedef std::deque<Query> query_queue_t;
query_queue_t query_queue;
void dispatchQueryResults(qmf::ConsoleEvent& event);
// remember the broker object so we can make qmf calls
qmf::Data brokerData;
};
#endif