MNE-CPP  beta 1.0
commandserver.h
Go to the documentation of this file.
1 //=============================================================================================================
36 #ifndef COMMANDSERVER_H
37 #define COMMANDSERVER_H
38 
39 //*************************************************************************************************************
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
45 #include <rtCommand/commandmanager.h>
46 
47 
48 //*************************************************************************************************************
49 //=============================================================================================================
50 // QT INCLUDES
51 //=============================================================================================================
52 
53 #include <QStringList>
54 #include <QTcpServer>
55 
56 
57 //*************************************************************************************************************
58 //=============================================================================================================
59 // DEFINE NAMESPACE RTSERVER
60 //=============================================================================================================
61 
62 namespace RTSERVER
63 {
64 
65 //*************************************************************************************************************
66 //=============================================================================================================
67 // USED NAMESPACES
68 //=============================================================================================================
69 
70 using namespace RTCOMMANDLIB;
71 
72 
73 //*************************************************************************************************************
74 //=============================================================================================================
75 // FORWARD DECLARATIONS
76 //=============================================================================================================
77 
78 //=============================================================================================================
84 class CommandServer : public QTcpServer
85 {
86  Q_OBJECT
87 public:
88 
89  //=========================================================================================================
95  CommandServer(QObject *parent = 0);
96 
97  //=========================================================================================================
101  virtual ~CommandServer();
102 
103  //=========================================================================================================
109  inline CommandParser& getCommandParser();
110 
111  //=========================================================================================================
118  void incommingCommand(QString p_sCommand, qint32 p_iThreadID);
119 
120  //=========================================================================================================
126  void registerCommandManager(CommandManager &p_commandManager);
127 
128  //=========================================================================================================
135  void prepareReply(QString p_sReply, Command p_command);
136 
137 signals:
138  //=========================================================================================================
145  void replyCommand(QString p_blockReply, qint32 p_iID);
146 
147  //=========================================================================================================
151  void closeCommandThreads();
152 
153 protected:
154  //=========================================================================================================
158  void incomingConnection(qintptr socketDescriptor);
159 
160 private:
161  qint32 m_iThreadCount;
163  CommandParser m_commandParser;
165 // QMultiMap<QString, qint32> m_qMultiMapCommandThreadID;//This is need when commands are processed by different threads; currently its only one command per time processed by one thread --> m_iCurrentCommandThreadID
166  qint32 m_iCurrentCommandThreadID;
167 };
168 
169 
170 //*************************************************************************************************************
171 //=============================================================================================================
172 // INLINE DEFINITIONS
173 //=============================================================================================================
174 
176 {
177  return m_commandParser;
178 }
179 
180 } // NAMESPACE
181 
182 #endif //INSTRUCTIONSERVER_H
Declaration of the CommandParser Class.
CommandParser & getCommandParser()
CommandServer manages threaded command connections.
Definition: commandserver.h:84