blob: 82bec399be6a50ab47a5b087ac3d9c3c0087d9b8 [file] [log] [blame]
Roger Meier86e89862012-02-10 19:53:20 +00001#ifndef _THRIFT_TASYNC_QTCP_SERVER_H_
2#define _THRIFT_TASYNC_QTCP_SERVER_H_
3
4#include <QObject>
5#include <QTcpServer>
6
7#include <boost/shared_ptr.hpp>
8
9#include <tr1/functional>
10
11namespace apache { namespace thrift { namespace protocol {
12class TProtocol;
13class TProtocolFactory;
14}}} // apache::thrift::protocol
15
16namespace apache { namespace thrift { namespace async {
17
18class TAsyncProcessor;
19
20class TQTcpServer : public QObject {
21 Q_OBJECT
22 public:
23 TQTcpServer(boost::shared_ptr<QTcpServer> server,
24 boost::shared_ptr<TAsyncProcessor> processor,
25 boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory,
26 QT_PREPEND_NAMESPACE(QObject)* parent = NULL);
27 virtual ~TQTcpServer();
28
29 private Q_SLOTS:
30 void processIncoming();
31 void beginDecode();
32 void socketClosed();
33
34 private:
35 class ConnectionContext;
36
37 void finish(boost::shared_ptr<ConnectionContext> ctx, bool healthy);
38
39 boost::shared_ptr<QTcpServer> server_;
40 boost::shared_ptr<TAsyncProcessor> processor_;
41 boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_;
42
43 std::map<QT_PREPEND_NAMESPACE(QTcpSocket)*, boost::shared_ptr<ConnectionContext> > ctxMap_;
44};
45
46}}} // apache::thrift::async
47
48#endif // #ifndef _THRIFT_TASYNC_QTCP_SERVER_H_