MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
commandmanager.h
1#ifndef COMMUNICATIONMANAGER_H
2#define COMMUNICATIONMANAGER_H
3
4//=============================================================================================================
5// Includes
6//=============================================================================================================
7
8#include "../communication_global.h"
9#include "command.h"
10#include "commandparser.h"
11
13
14//=============================================================================================================
15// Qt Includes
16//=============================================================================================================
17
18#include <QObject>
19#include <QJsonDocument>
20
21//=============================================================================================================
22// DEFINE NAMESPACE COMMUNICATIONLIB
23//=============================================================================================================
24
25namespace COMMUNICATIONLIB
26{
27
28//=============================================================================================================
29// FORWARD DECLARATIONS
30//=============================================================================================================
31
32//=============================================================================================================
37{
38 Q_OBJECT
39
40public:
41 explicit CommandManager(bool p_bIsActive = true, QObject *parent = 0);
42
43 explicit CommandManager(const QByteArray &p_qByteArrayJsonDoc, bool p_bIsActive = true, QObject *parent = 0);
44
45 explicit CommandManager(const QJsonDocument &p_jsonDoc, bool p_bIsActive = true, QObject *parent = 0);
46
47 virtual ~CommandManager();
48
49 //=========================================================================================================
53 void clear();
54
55 //=========================================================================================================
61 inline QMap<QString, Command>& commandMap();
62
63 //=========================================================================================================
71 inline bool hasCommand(const QString &p_sCommand) const;
72
73 //=========================================================================================================
80 void insert(const QJsonDocument &p_jsonDocument);
81
82 //=========================================================================================================
89 void insert(const QString &p_sKey, const QString &p_sDescription);
90
91 //=========================================================================================================
98 void insert(const QString &p_sKey, const Command &p_command);
99
100 //=========================================================================================================
106 inline bool isActive() const;
107
108 //=========================================================================================================
114 inline void setStatus(bool status);
115
116 //=========================================================================================================
122 virtual void update(UTILSLIB::Subject* p_pSubject);
123
124 //=========================================================================================================
132 Command& operator[] (const QString &key);
133
134 //=========================================================================================================
142 const Command operator[] (const QString &key) const;
143
144private:
145 //=========================================================================================================
149 void init();
150
151 bool m_bIsActive;
152
153 QJsonDocument m_jsonDocumentOrigin;
154
155 QMetaObject::Connection m_conReplyChannel;
157 QMap<QString, Command> m_qMapCommands;
159signals:
160 void commandMapChanged();//(QStringList)
161
162 //=========================================================================================================
168 void triggered(Command p_command);
169
170 //=========================================================================================================
177 void response(QString p_sReply, Command p_command);
178};
179
180//=============================================================================================================
181// INLINE DEFINITIONS
182//=============================================================================================================
183
184inline QMap<QString, Command>& CommandManager::commandMap()
185{
186 return m_qMapCommands;
187}
188
189//=============================================================================================================
190
191inline bool CommandManager::hasCommand(const QString &p_sCommand) const
192{
193 return m_qMapCommands.contains(p_sCommand);
194}
195
196//=============================================================================================================
197
198inline bool CommandManager::isActive() const
199{
200 return m_bIsActive;
201}
202
203//=============================================================================================================
204
205inline void CommandManager::setStatus(bool status)
206{
207 m_bIsActive = status;
208}
209} // NAMESPACE
210
211#endif // COMMUNICATIONMANAGER_H
Contains declarations of the observer design pattern: Subject class and IObserver interface.
#define COMMUNICATIONSHARED_EXPORT
Declaration of the CommandParser Class.
Declaration of the Command Class.
QMap< QString, Command > & commandMap()
void triggered(Command p_command)
bool hasCommand(const QString &p_sCommand) const
void response(QString p_sReply, Command p_command)
The IObserver interface provides the base class of every observer of the observer design pattern.
The Subject class provides the base class of every subject of the observer design pattern.