Roger Meier | 86e8986 | 2012-02-10 19:53:20 +0000 | [diff] [blame] | 1 | #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 | |
| 11 | namespace apache { namespace thrift { namespace protocol { |
| 12 | class TProtocol; |
| 13 | class TProtocolFactory; |
| 14 | }}} // apache::thrift::protocol |
| 15 | |
| 16 | namespace apache { namespace thrift { namespace async { |
| 17 | |
| 18 | class TAsyncProcessor; |
| 19 | |
| 20 | class 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_ |