MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
command.h
Go to the documentation of this file.
1//=============================================================================================================
37#ifndef COMMAND_H
38#define COMMAND_H
39
40//=============================================================================================================
41// INCLUDES
42//=============================================================================================================
43
44#include "../communication_global.h"
45
47
48//=============================================================================================================
49// QT INCLUDES
50//=============================================================================================================
51
52#include <QObject>
53#include <QList>
54#include <QString>
55#include <QVariant>
56#include <QJsonObject>
57#include <QSharedPointer>
58#include <QDebug>
59#include <QPair>
60#include <QStringList>
61
62//=============================================================================================================
63// DEFINE NAMESPACE COMMUNICATIONLIB
64//=============================================================================================================
65
66namespace COMMUNICATIONLIB
67{
68
69static QVariant defaultVariant;
70
71//=============================================================================================================
78{
79Q_OBJECT
80
81public:
82 typedef QSharedPointer<Command> SPtr;
83 typedef QSharedPointer<const Command> ConstSPtr;
84
85 //=========================================================================================================
92 explicit Command(bool p_bIsJson = true, QObject *parent = 0);
93
94 //=========================================================================================================
103 explicit Command(const QString &p_sCommand, const QJsonObject &p_qCommandContent, bool p_bIsJson = true, QObject *parent = 0);
104
105 //=========================================================================================================
114 explicit Command(const QString &p_sCommand, const QString &p_sDescription, bool p_bIsJson = true, QObject *parent = 0);
115
116 //=========================================================================================================
127 explicit Command(const QString &p_sCommand, const QString &p_sDescription,
128 const QStringList &p_qListParamNames, const QList<QVariant> &p_qListParamValues, bool p_bIsJson = true, QObject *parent = 0);
129
130 //=========================================================================================================
140 explicit Command(const QString &p_sCommand, const QString &p_sDescription,
141 const QStringList &p_qListParamNames, const QList<QVariant> &p_qListParamValues, const QStringList &p_vecParameterDescriptions, bool p_bIsJson = true, QObject *parent = 0);
142
143 //=========================================================================================================
149 Command(const Command &p_Command);
150
151 //=========================================================================================================
155 virtual ~Command();
156
157 //=========================================================================================================
163 inline QString command() const;
164
165 //=========================================================================================================
171 inline quint32 count() const;
172
173 //=========================================================================================================
179 inline QString description() const;
180
181 //=========================================================================================================
187 virtual void execute();
188
189 //=========================================================================================================
195 inline bool& isJson();
196
197 //=========================================================================================================
203 inline QList<QString> pDescriptions() const;
204
205 //=========================================================================================================
211 inline QList<QString> pNames() const;
212
213 //=========================================================================================================
219 inline QList<QVariant>& pValues();
220
221 //=========================================================================================================
227 void reply(const QString &p_sReply);
228
229 //=========================================================================================================
233 void send();
234
235 //=========================================================================================================
241 QJsonObject toJsonObject() const;
242
243 //=========================================================================================================
249 QStringList toStringList() const;
250
251 //=========================================================================================================
257 QString toStringReadySend() const;
258
259 //=========================================================================================================
265 Command& operator= (const Command &rhs);
266
267 //=========================================================================================================
275 QVariant& operator[] (const QString &key);
276
277 //=========================================================================================================
285 QVariant& operator[] (qint32 idx);
286
287 //=========================================================================================================
295 const QVariant operator[] (const QString &key) const;
296
297signals:
298 //=========================================================================================================
304 void executed(Command p_command);
305
306public:
307 QString m_sCommand;
308 QString m_sDescription;
309 QStringList m_qListParamNames;
310 QList<QVariant> m_qListParamValues;
311 QStringList m_qListParamDescriptions;
312 bool m_bIsJson;
313};
314
315//=============================================================================================================
316// INLINE DEFINITIONS
317//=============================================================================================================
318
319inline QString Command::command() const
320{
321 return m_sCommand;
322}
323
324//=============================================================================================================
325
326inline quint32 Command::count() const
327{
328 return m_qListParamValues.size();
329}
330
331//=============================================================================================================
332
333inline QString Command::description() const
334{
335 return m_sDescription;
336}
337
338//=============================================================================================================
339
340inline bool& Command::isJson()
341{
342 return m_bIsJson;
343}
344
345//=============================================================================================================
346
347inline QList<QString> Command::pDescriptions() const
348{
349 return m_qListParamDescriptions;
350}
351
352//=============================================================================================================
353
354inline QList<QString> Command::pNames() const
355{
356 return m_qListParamNames;
357}
358
359//=============================================================================================================
360
361inline QList<QVariant>& Command::pValues()
362{
363 return m_qListParamValues;
364}
365} // NAMESPACE
366
367#endif // COMMAND_H
Contains declarations of the command design pattern: ICommand interface.
#define COMMUNICATIONSHARED_EXPORT
QString description() const
Definition command.h:333
QList< QVariant > & pValues()
Definition command.h:361
QList< QString > pNames() const
Definition command.h:354
void executed(Command p_command)
QList< QString > pDescriptions() const
Definition command.h:347
QString command() const
Definition command.h:319
quint32 count() const
Definition command.h:326
The ICommand interface provides the base class of every command of the command design pattern.