Receptacle
 All Classes Files Functions Variables Pages
dispatcher.h
1 /*
2 
3 Copyright 2014 William Wedler
4 
5 This file is part of Receptacle
6 
7 Receptacle is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Receptacle is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Receptacle. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 
22 
23 // dispatcher.h
24 
25 #ifndef DISPATCHER_H
26 #define DISPATCHER_H
27 
28 #include <QDir>
29 #include <QTcpServer>
30 #include <QTcpSocket>
31 #include <QAbstractSocket>
32 #include <QSemaphore>
33 
34 
35 #include "host_controller.h"
36 #include "client_connection.h"
37 
38 class Dispatcher : public QTcpServer
39 {
40  Q_OBJECT
41 public:
42  ~Dispatcher();
43  explicit Dispatcher(HostController* h_controller, QObject *parent = 0);
44 
48  void startServer(int port);
49 
54  bool queue_busy();
55 
56  protected:
57  void incomingConnection(qintptr socketDescriptor);
58 
59  protected:
60  HostController* controller;
61  QSemaphore request_mutex;
62 
63 public slots:
68  void queue_request(QString command);
69 
74  void request_completed(const QString &command);
75 
76 };
77 
78 #endif // DISPATCHER_H
Definition: host_controller.h:39
Definition: dispatcher.h:38
void request_completed(const QString &command)
Handler to cleanup after a job finishes and prepares for the next job to run.
Definition: dispatcher.cpp:87
bool queue_busy()
A 'busy signal' check.
Definition: dispatcher.cpp:80
void startServer(int port)
Call startServer to listen for client connections. Server does not process requests until this is cal...
Definition: dispatcher.cpp:43
void queue_request(QString command)
Asynchronous request for a job to run.
Definition: dispatcher.cpp:68