Change Thrift c++ to new protocol wrapping transport model

Summary: Also cleaned up excessive .h/.cpp files into Utils files

Reviewed By: aditya


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664838 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TNonblockingServer.h b/lib/cpp/src/server/TNonblockingServer.h
index ec024c0..faa572f 100644
--- a/lib/cpp/src/server/TNonblockingServer.h
+++ b/lib/cpp/src/server/TNonblockingServer.h
@@ -1,9 +1,9 @@
 #ifndef _THRIFT_SERVER_TNONBLOCKINGSERVER_H_
 #define _THRIFT_SERVER_TNONBLOCKINGSERVER_H_ 1
 
-#include "Thrift.h"
-#include "server/TServer.h"
-#include "transport/TMemoryBuffer.h"
+#include <Thrift.h>
+#include <server/TServer.h>
+#include <transport/TTransportUtils.h>
 #include <stack>
 #include <event.h>
 
@@ -50,10 +50,8 @@
   void handleEvent(int fd, short which);
 
  public:
-  TNonblockingServer(shared_ptr<TProcessor> processor,
-                     shared_ptr<TServerOptions> options,
-                     int port) :
-    TServer(processor, options),
+  TNonblockingServer(shared_ptr<TProcessor> processor, int port) :
+    TServer(processor),
     serverSocket_(0),
     port_(port),
     frameResponses_(true) {}
@@ -157,6 +155,12 @@
   // Transport that processor writes to
   shared_ptr<TMemoryBuffer> outputTransport_;
 
+  // Protocol encoder
+  shared_ptr<TProtocol> outputProtocol_;
+
+  // Protocol decoder
+  shared_ptr<TProtocol> inputProtocol_;
+  
   // Go into read mode
   void setRead() {
     setFlags(EV_READ | EV_PERSIST);
@@ -190,6 +194,12 @@
     inputTransport_ = shared_ptr<TMemoryBuffer>(new TMemoryBuffer(readBuffer_, readBufferSize_));
     outputTransport_ = shared_ptr<TMemoryBuffer>(new TMemoryBuffer());
     
+    // Create protocol
+    std::pair<shared_ptr<TProtocol>,shared_ptr<TProtocol> > iop;
+    iop = s->getProtocolFactory()->getIOProtocols(inputTransport_, outputTransport_);
+    inputProtocol_ = iop.first;
+    outputProtocol_ = iop.second;
+
     init(socket, eventFlags, s);
   }