MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
rtcmdclient.h
Go to the documentation of this file.
1//=============================================================================================================
37#ifndef RTCMDCLIENT_H
38#define RTCMDCLIENT_H
39
40//=============================================================================================================
41// INCLUDES
42//=============================================================================================================
43
44#include "../communication_global.h"
45#include "../rtCommand/commandmanager.h"
46#include "../rtCommand/command.h"
47
48//=============================================================================================================
49// QT INCLUDES
50//=============================================================================================================
51
52#include <QDataStream>
53#include <QMutex>
54#include <QSharedPointer>
55#include <QString>
56#include <QTcpSocket>
57
58//=============================================================================================================
59// DEFINE NAMESPACE COMMUNICATIONLIB
60//=============================================================================================================
61
62namespace COMMUNICATIONLIB
63{
64
65//=============================================================================================================
71class COMMUNICATIONSHARED_EXPORT RtCmdClient : public QTcpSocket
72{
73 Q_OBJECT
74
75public:
76 typedef QSharedPointer<RtCmdClient> SPtr;
77 typedef QSharedPointer<const RtCmdClient> ConstSPtr;
79 //=========================================================================================================
85 explicit RtCmdClient(QObject *parent = Q_NULLPTR);
86
87 //=========================================================================================================
95 inline bool hasCommand(const QString &p_sCommand) const;
96
97 //=========================================================================================================
105 QString sendCLICommand(const QString &p_sCommand);
106
107 //=========================================================================================================
115 void sendCommandJSON(const Command &p_command);
116
117 //=========================================================================================================
123 inline QString readAvailableData();
124
125 //=========================================================================================================
129 qint32 requestBufsize();
130
131 //=========================================================================================================
135 void requestCommands();
136
137 //=========================================================================================================
145 qint32 requestConnectors(QMap<qint32, QString> &p_qMapConnectors);
146
147 //=========================================================================================================
155 bool waitForDataAvailable(qint32 msecs = 30000) const;
156
157 //=========================================================================================================
165 Command& operator[] (const QString &key);
166
167 //=========================================================================================================
175 const Command operator[] (const QString &key) const;
176
177signals:
178 //=========================================================================================================
184 void response(QString p_sResponse);
185
186private:
187 CommandManager m_commandManager;
188 QMutex m_qMutex;
189 QString m_sAvailableData;
190};
191
192//=============================================================================================================
193// INLINE DEFINITIONS
194//=============================================================================================================
195
197{
198 m_qMutex.lock();
199 QString p_sResponse = m_sAvailableData;
200 m_sAvailableData.clear();
201 m_qMutex.unlock();
202
203 return p_sResponse;
204}
205
206//=============================================================================================================
207
208inline bool RtCmdClient::hasCommand(const QString &p_sCommand) const
209{
210 return m_commandManager.hasCommand(p_sCommand);
211}
212} // NAMESPACE
213
214#endif // RTCMDCLIENT_H
#define COMMUNICATIONSHARED_EXPORT
Real-time command client.
Definition rtcmdclient.h:72
void response(QString p_sResponse)
bool hasCommand(const QString &p_sCommand) const
QSharedPointer< const RtCmdClient > ConstSPtr
Definition rtcmdclient.h:77
QSharedPointer< RtCmdClient > SPtr
Definition rtcmdclient.h:76
bool hasCommand(const QString &p_sCommand) const