More boosification of thrift driver, server, transport and protocol code

Modified TestServer to use thread-pool manager 


	


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664737 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.cc b/lib/cpp/src/protocol/TBinaryProtocol.cc
index ed482b8..fef8ab4 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.cc
+++ b/lib/cpp/src/protocol/TBinaryProtocol.cc
@@ -3,16 +3,28 @@
 
 namespace facebook { namespace thrift { namespace protocol { 
 
-uint32_t TBinaryProtocol::writeStructBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeMessageBegin(shared_ptr<TTransport> out,
+					    const TMessageType messageType,
+					    const uint32_t seqid) const {
+  return 
+    writeByte(out, (uint8_t)messageType) +
+    writeU32(out, seqid);
+}
+
+uint32_t TBinaryProtocol::writeMessageEnd(shared_ptr<TTransport> out) const {
+  return 0;
+}
+
+uint32_t TBinaryProtocol::writeStructBegin(shared_ptr<TTransport> out,
                                            const string& name) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::writeStructEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeStructEnd(shared_ptr<TTransport> out) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::writeFieldBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeFieldBegin(shared_ptr<TTransport> out,
                                           const string& name,
                                           const TType fieldType,
                                           const uint16_t fieldId) const {
@@ -21,16 +33,16 @@
     writeI32(out, (int32_t)fieldId);
 }
 
-uint32_t TBinaryProtocol::writeFieldEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeFieldEnd(shared_ptr<TTransport> out) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::writeFieldStop(TTransport* out) const {
+uint32_t TBinaryProtocol::writeFieldStop(shared_ptr<TTransport> out) const {
   return
     writeByte(out, (uint8_t)T_STOP);
 }  
                                
-uint32_t TBinaryProtocol::writeMapBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeMapBegin(shared_ptr<TTransport> out,
                                         const TType keyType,
                                         const TType valType,
                                         const int32_t size) const {
@@ -40,11 +52,11 @@
     writeI32(out, (int32_t)size);
 }
 
-uint32_t TBinaryProtocol::writeMapEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeMapEnd(shared_ptr<TTransport> out) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::writeListBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeListBegin(shared_ptr<TTransport> out,
                                          const TType elemType,
                                          const int32_t size) const {
   return
@@ -52,11 +64,11 @@
     writeI32(out, (int32_t)size);
 }
 
-uint32_t TBinaryProtocol::writeListEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeListEnd(shared_ptr<TTransport> out) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::writeSetBegin(TTransport* out,
+uint32_t TBinaryProtocol::writeSetBegin(shared_ptr<TTransport> out,
                                         const TType elemType,
                                         const int32_t size) const {
   return
@@ -64,45 +76,45 @@
     writeI32(out, (int32_t)size);
 }
 
-uint32_t TBinaryProtocol::writeSetEnd(TTransport* out) const {
+uint32_t TBinaryProtocol::writeSetEnd(shared_ptr<TTransport> out) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::writeByte(TTransport* out,
+uint32_t TBinaryProtocol::writeByte(shared_ptr<TTransport> out,
                                     const uint8_t byte) const {
   out->write(&byte, 1);
   return 1;
 }
 
-uint32_t TBinaryProtocol::writeU32(TTransport* out,
+uint32_t TBinaryProtocol::writeU32(shared_ptr<TTransport> out,
                                    const uint32_t u32) const {
   uint32_t net = (uint32_t)htonl(u32);
   out->write((uint8_t*)&net, 4);
   return 4;
 }
 
-uint32_t TBinaryProtocol::writeI32(TTransport* out,
+uint32_t TBinaryProtocol::writeI32(shared_ptr<TTransport> out,
                                    const int32_t i32) const {
   int32_t net = (int32_t)htonl(i32);
   out->write((uint8_t*)&net, 4);
   return 4;
 }
 
-uint32_t TBinaryProtocol::writeU64(TTransport* out,
+uint32_t TBinaryProtocol::writeU64(shared_ptr<TTransport> out,
                                    const uint64_t u64) const {
   uint64_t net = (uint64_t)htonll(u64);
   out->write((uint8_t*)&net, 8);
   return 8;
 }
 
-uint32_t TBinaryProtocol::writeI64(TTransport* out,
+uint32_t TBinaryProtocol::writeI64(shared_ptr<TTransport> out,
                                    const int64_t i64) const {
   int64_t net = (int64_t)htonll(i64);
   out->write((uint8_t*)&net, 8);
   return 8;
 }
 
-uint32_t TBinaryProtocol::writeString(TTransport* out,
+uint32_t TBinaryProtocol::writeString(shared_ptr<TTransport> out,
                                       const string& str) const {
   uint32_t result = writeI32(out, str.size());
   out->write((uint8_t*)str.data(), str.size());
@@ -113,17 +125,33 @@
  * Reading functions
  */
 
-uint32_t TBinaryProtocol::readStructBegin(TTransport* in,
+uint32_t TBinaryProtocol::readMessasgeBegin(shared_ptr<TTransport> in,
+					    TMessageType& messageType,
+					    uint32_t& seqid) const {
+
+  uint32_t result = 0;
+  uint8_t type;
+  result+=  readByte(in, type);
+  messageType = (TMessageType)type;
+  result+= readU32(in, seqid);
+  return result;
+}
+
+uint32_t TBinaryProtocol::readMessageEnd(shared_ptr<TTransport> in)  const{
+  return 0;
+}
+
+uint32_t TBinaryProtocol::readStructBegin(shared_ptr<TTransport> in,
                                           string& name) const {
   name = "";
   return 0;
 }
 
-uint32_t TBinaryProtocol::readStructEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readStructEnd(shared_ptr<TTransport> in) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::readFieldBegin(TTransport* in,
+uint32_t TBinaryProtocol::readFieldBegin(shared_ptr<TTransport> in,
                                          string& name,
                                          TType& fieldType,
                                          uint16_t& fieldId) const {
@@ -141,11 +169,11 @@
   return result;
 }
   
-uint32_t TBinaryProtocol::readFieldEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readFieldEnd(shared_ptr<TTransport> in) const {
   return 0;
 }
  
-uint32_t TBinaryProtocol::readMapBegin(TTransport* in,
+uint32_t TBinaryProtocol::readMapBegin(shared_ptr<TTransport> in,
                                        TType& keyType,
                                        TType& valType,
                                        int32_t& size) const {
@@ -159,11 +187,11 @@
   return result;
 }
 
-uint32_t TBinaryProtocol::readMapEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readMapEnd(shared_ptr<TTransport> in) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::readListBegin(TTransport* in,
+uint32_t TBinaryProtocol::readListBegin(shared_ptr<TTransport> in,
                                         TType& elemType,
                                         int32_t& size) const {
   uint8_t e;
@@ -174,11 +202,11 @@
   return result;
 }
 
-uint32_t TBinaryProtocol::readListEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readListEnd(shared_ptr<TTransport> in) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::readSetBegin(TTransport* in,
+uint32_t TBinaryProtocol::readSetBegin(shared_ptr<TTransport> in,
                                        TType& elemType,
                                        int32_t& size) const {
   uint8_t e;
@@ -189,11 +217,11 @@
   return result;
 }
 
-uint32_t TBinaryProtocol::readSetEnd(TTransport* in) const {
+uint32_t TBinaryProtocol::readSetEnd(shared_ptr<TTransport> in) const {
   return 0;
 }
 
-uint32_t TBinaryProtocol::readByte(TTransport* in,
+uint32_t TBinaryProtocol::readByte(shared_ptr<TTransport> in,
                                    uint8_t& byte) const {
   uint8_t b[1];
   in->readAll(b, 1);
@@ -201,7 +229,7 @@
   return 1;
 }
 
-uint32_t TBinaryProtocol::readU32(TTransport* in,
+uint32_t TBinaryProtocol::readU32(shared_ptr<TTransport> in,
                                   uint32_t& u32) const {
   uint8_t b[4];
   in->readAll(b, 4);
@@ -210,7 +238,7 @@
   return 4;
 }
 
-uint32_t TBinaryProtocol::readI32(TTransport* in,
+uint32_t TBinaryProtocol::readI32(shared_ptr<TTransport> in,
                                   int32_t& i32) const {
   uint8_t b[4];
   in->readAll(b, 4);
@@ -219,7 +247,7 @@
   return 4;
 }
 
-uint32_t TBinaryProtocol::readU64(TTransport* in,
+uint32_t TBinaryProtocol::readU64(shared_ptr<TTransport> in,
                                   uint64_t& u64) const {
   uint8_t b[8];
   in->readAll(b, 8);
@@ -228,7 +256,7 @@
   return 8;
 }
 
-uint32_t TBinaryProtocol::readI64(TTransport* in,
+uint32_t TBinaryProtocol::readI64(shared_ptr<TTransport> in,
                                   int64_t& i64) const {
   uint8_t b[8];
   in->readAll(b, 8);
@@ -237,7 +265,7 @@
   return 8;
 }
 
-uint32_t TBinaryProtocol::readString(TTransport* in,
+uint32_t TBinaryProtocol::readString(shared_ptr<TTransport> in,
                                      string& str) const {
   uint32_t result;
   int32_t size;
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.h b/lib/cpp/src/protocol/TBinaryProtocol.h
index 0f0560a..3456abf 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/protocol/TBinaryProtocol.h
@@ -1,10 +1,14 @@
 #ifndef T_BINARY_PROTOCOL_H
 #define T_BINARY_PROTOCOL_H
 
-#include "protocol/TProtocol.h"
+#include <protocol/TProtocol.h>
+
+#include <boost/shared_ptr.hpp>
 
 namespace facebook { namespace thrift { namespace protocol { 
 
+using namespace boost;
+
 /**
  * The default binary protocol for thrift. Writes all data in a very basic
  * binary format, essentially just spitting out the raw bytes.
@@ -12,7 +16,7 @@
  * @author Mark Slee <mcslee@facebook.com>
  */
 class TBinaryProtocol : public TProtocol {
- public:
+  public:
   TBinaryProtocol() {}
   ~TBinaryProtocol() {}
 
@@ -20,108 +24,122 @@
    * Writing functions.
    */
 
-  uint32_t writeStructBegin   (TTransport*    out,
+  virtual uint32_t writeMessageBegin(shared_ptr<TTransport> out,
+				     const TMessageType messageType,
+				     const uint32_t seqid) const;
+
+  virtual uint32_t writeMessageEnd   (shared_ptr<TTransport> out) const;
+
+
+  uint32_t writeStructBegin   (shared_ptr<TTransport>    out,
                                const std::string& name)   const;
 
-  uint32_t writeStructEnd     (TTransport*    out)        const;
+  uint32_t writeStructEnd     (shared_ptr<TTransport>    out)        const;
 
-  uint32_t writeFieldBegin    (TTransport*    out,
+  uint32_t writeFieldBegin    (shared_ptr<TTransport>    out,
                                const std::string& name,
                                const TType    fieldType,
                                const uint16_t fieldId)    const;
 
-  uint32_t writeFieldEnd      (TTransport*    out)        const;
+  uint32_t writeFieldEnd      (shared_ptr<TTransport>    out)        const;
 
-  uint32_t writeFieldStop     (TTransport*    out)        const;
+  uint32_t writeFieldStop     (shared_ptr<TTransport>    out)        const;
                                        
-  uint32_t writeMapBegin      (TTransport*    out,
+  uint32_t writeMapBegin      (shared_ptr<TTransport>    out,
                                const TType    keyType,
                                const TType    valType,
                                const int32_t  size)       const;
 
-  uint32_t writeMapEnd        (TTransport*    out)        const;
+  uint32_t writeMapEnd        (shared_ptr<TTransport>    out)        const;
 
-  uint32_t writeListBegin     (TTransport*    out,
+  uint32_t writeListBegin     (shared_ptr<TTransport>    out,
                                const TType    elemType,
                                const int32_t  size)       const;
 
-  uint32_t writeListEnd       (TTransport*    out)        const;
+  uint32_t writeListEnd       (shared_ptr<TTransport>    out)        const;
 
-  uint32_t writeSetBegin      (TTransport*    out,
+  uint32_t writeSetBegin      (shared_ptr<TTransport>    out,
                                const TType    elemType,
                                const int32_t  size)       const;
 
-  uint32_t writeSetEnd        (TTransport*    out)        const;
+  uint32_t writeSetEnd        (shared_ptr<TTransport>    out)        const;
 
-  uint32_t writeByte          (TTransport*    out,
+  uint32_t writeByte          (shared_ptr<TTransport>    out,
                                const uint8_t  byte)       const;
 
-  uint32_t writeU32           (TTransport*    out,
+  uint32_t writeU32           (shared_ptr<TTransport>    out,
                                const uint32_t u32)        const;
 
-  uint32_t writeI32           (TTransport*    out,
+  uint32_t writeI32           (shared_ptr<TTransport>    out,
                                const int32_t  i32)        const;
 
-  uint32_t writeU64           (TTransport*    out,
+  uint32_t writeU64           (shared_ptr<TTransport>    out,
                                const uint64_t u64)        const;
 
-  uint32_t writeI64           (TTransport*    out,
+  uint32_t writeI64           (shared_ptr<TTransport>    out,
                                const int64_t  i64)        const;
 
-  uint32_t writeString        (TTransport*    out,
+  uint32_t writeString        (shared_ptr<TTransport>    out,
                                const std::string& str)    const;
 
   /**
    * Reading functions
    */
 
-  uint32_t readStructBegin    (TTransport*    in,
+
+  uint32_t readMessasgeBegin    (shared_ptr<TTransport>    in,
+				 TMessageType& messageType,
+				 uint32_t& seqid) const;
+
+  uint32_t readMessageEnd      (shared_ptr<TTransport>    in) const;
+
+  uint32_t readStructBegin    (shared_ptr<TTransport>    in,
                                std::string& name)         const;
 
-  uint32_t readStructEnd      (TTransport*    in)         const;
+  uint32_t readStructEnd      (shared_ptr<TTransport>    in)         const;
 
-  uint32_t readFieldBegin     (TTransport*    in,
+  uint32_t readFieldBegin     (shared_ptr<TTransport>    in,
                                std::string&   name,
                                TType&         fieldType,
                                uint16_t&      fieldId)    const;
   
-  uint32_t readFieldEnd       (TTransport*    in)         const;
+  uint32_t readFieldEnd       (shared_ptr<TTransport>    in)         const;
  
-  uint32_t readMapBegin       (TTransport*    in,
+  uint32_t readMapBegin       (shared_ptr<TTransport>    in,
                                TType&         keyType,
                                TType&         valType,
                                int32_t&       size)       const;
 
-  uint32_t readMapEnd         (TTransport*    in)         const;
+  uint32_t readMapEnd         (shared_ptr<TTransport>    in)         const;
 
-  uint32_t readListBegin      (TTransport*    in,
+  uint32_t readListBegin      (shared_ptr<TTransport>    in,
                                TType&         elemType,
                                int32_t&       size)       const;
   
-  uint32_t readListEnd        (TTransport*    in)         const;
+  uint32_t readListEnd        (shared_ptr<TTransport>    in)         const;
 
-  uint32_t readSetBegin       (TTransport*    in,
+  uint32_t readSetBegin       (shared_ptr<TTransport>    in,
                                TType&         elemType,
                                int32_t&       size)       const;
 
-  uint32_t readSetEnd         (TTransport*    in)         const;
+  uint32_t readSetEnd         (shared_ptr<TTransport>    in)         const;
 
-  uint32_t readByte           (TTransport*    in,
+  uint32_t readByte           (shared_ptr<TTransport>    in,
                                uint8_t&       byte)       const;
 
-  uint32_t readU32            (TTransport*    in,
+  uint32_t readU32            (shared_ptr<TTransport>    in,
                                uint32_t&      u32)        const;
 
-  uint32_t readI32            (TTransport*    in,
+  uint32_t readI32            (shared_ptr<TTransport>    in,
                                int32_t&       i32)        const;
 
-  uint32_t readU64            (TTransport*    in,
+  uint32_t readU64            (shared_ptr<TTransport>    in,
                                uint64_t&      u64)        const;
 
-  uint32_t readI64            (TTransport*    in,
+  uint32_t readI64            (shared_ptr<TTransport>    in,
                                int64_t&       i64)        const;
 
-  uint32_t readString         (TTransport*    in,
+  uint32_t readString         (shared_ptr<TTransport>    in,
                                std::string&   str)        const;
 
 };
diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h
index 40beadd..33a6eb7 100644
--- a/lib/cpp/src/protocol/TProtocol.h
+++ b/lib/cpp/src/protocol/TProtocol.h
@@ -1,15 +1,19 @@
 #ifndef T_PROTOCOL_H
 #define T_PROTOCOL_H
 
+#include <transport/TTransport.h>
+
+#include <boost/shared_ptr.hpp>
+
 #include <netinet/in.h>
 #include <sys/types.h>
 #include <string>
 #include <map>
 
-#include "transport/TTransport.h"
-
 namespace facebook { namespace thrift { namespace protocol { 
 
+using namespace boost;
+
 using namespace facebook::thrift::transport;
 
 #define ntohll(x) (((uint64_t)(ntohl((int)((x << 32) >> 32))) << 32) | (uint32_t)ntohl(((int)(x >> 32))))
@@ -41,6 +45,14 @@
 };
 
 /**
+ * Enumerated definition of the message types that the Thrift protocol supports.
+ */
+enum TMessageType {
+  T_CALL       = 1,
+  T_REPLY      = 2
+};
+
+/**
  * Abstract class for a thrift protocol driver. These are all the methods that
  * a protocol must implement. Essentially, there must be some way of reading
  * and writing all the base types, plus a mechanism for writing out structs
@@ -60,114 +72,127 @@
    * Writing functions.
    */
 
-  virtual uint32_t writeStructBegin   (TTransport*    out,
+  virtual uint32_t writeMessageBegin   (shared_ptr<TTransport> out,
+					const TMessageType messageType,
+					const uint32_t seqid) const = 0;
+
+  virtual uint32_t writeMessageEnd   (shared_ptr<TTransport> out) const = 0;
+
+
+  virtual uint32_t writeStructBegin   (shared_ptr<TTransport>    out,
                                        const std::string& name)   const = 0;
 
-  virtual uint32_t writeStructEnd     (TTransport*    out)        const = 0;
+  virtual uint32_t writeStructEnd     (shared_ptr<TTransport>    out)        const = 0;
 
-  virtual uint32_t writeFieldBegin    (TTransport*    out,
+  virtual uint32_t writeFieldBegin    (shared_ptr<TTransport>    out,
                                        const std::string& name,
                                        const TType    fieldType,
                                        const uint16_t fieldId)    const = 0;
 
-  virtual uint32_t writeFieldEnd      (TTransport*    out)        const = 0;
+  virtual uint32_t writeFieldEnd      (shared_ptr<TTransport>    out)        const = 0;
 
-  virtual uint32_t writeFieldStop     (TTransport*    out)        const = 0;
+  virtual uint32_t writeFieldStop     (shared_ptr<TTransport>    out)        const = 0;
                                       
-  virtual uint32_t writeMapBegin      (TTransport*    out,
+  virtual uint32_t writeMapBegin      (shared_ptr<TTransport>    out,
                                        const TType    keyType,
                                        const TType    valType,
                                        const int32_t  size)       const = 0;
 
-  virtual uint32_t writeMapEnd        (TTransport*    out)        const = 0;
+  virtual uint32_t writeMapEnd        (shared_ptr<TTransport>    out)        const = 0;
 
-  virtual uint32_t writeListBegin     (TTransport*    out,
+  virtual uint32_t writeListBegin     (shared_ptr<TTransport>    out,
                                        const TType    elemType,
                                        const int32_t  size)       const = 0;
 
-  virtual uint32_t writeListEnd       (TTransport*    out)        const = 0;
+  virtual uint32_t writeListEnd       (shared_ptr<TTransport>    out)        const = 0;
 
-  virtual uint32_t writeSetBegin      (TTransport*    out,
+  virtual uint32_t writeSetBegin      (shared_ptr<TTransport>    out,
                                        const TType    elemType,
                                        const int32_t  size)       const = 0;
 
-  virtual uint32_t writeSetEnd        (TTransport*    out)        const = 0;
+  virtual uint32_t writeSetEnd        (shared_ptr<TTransport>    out)        const = 0;
 
-  virtual uint32_t writeByte          (TTransport*    out,
+  virtual uint32_t writeByte          (shared_ptr<TTransport>    out,
                                        const uint8_t  byte)       const = 0;
 
-  virtual uint32_t writeU32           (TTransport*    out,
+  virtual uint32_t writeU32           (shared_ptr<TTransport>    out,
                                        const uint32_t u32)        const = 0;
 
-  virtual uint32_t writeI32           (TTransport*    out,
+  virtual uint32_t writeI32           (shared_ptr<TTransport>    out,
                                        const int32_t  i32)        const = 0;
 
-  virtual uint32_t writeU64           (TTransport*    out,
+  virtual uint32_t writeU64           (shared_ptr<TTransport>    out,
                                        const uint64_t u64)        const = 0;
 
-  virtual uint32_t writeI64           (TTransport*    out,
+  virtual uint32_t writeI64           (shared_ptr<TTransport>    out,
                                        const int64_t  i64)        const = 0;
 
-  virtual uint32_t writeString        (TTransport*    out,
+  virtual uint32_t writeString        (shared_ptr<TTransport>    out,
                                        const std::string& str)    const = 0;
 
   /**
    * Reading functions
    */
 
-  virtual uint32_t readStructBegin    (TTransport*    in,
+  virtual uint32_t readMessasgeBegin    (shared_ptr<TTransport>    in,
+					 TMessageType& messageType,
+					 uint32_t& seqid) const = 0;
+
+  virtual uint32_t readMessageEnd      (shared_ptr<TTransport>    in)         const = 0;
+
+  virtual uint32_t readStructBegin    (shared_ptr<TTransport>    in,
                                        std::string& name)         const = 0;
 
-  virtual uint32_t readStructEnd      (TTransport*    in)         const = 0;
+  virtual uint32_t readStructEnd      (shared_ptr<TTransport>    in)         const = 0;
 
-  virtual uint32_t readFieldBegin     (TTransport*    in,
+  virtual uint32_t readFieldBegin     (shared_ptr<TTransport>    in,
                                        std::string&   name,
                                        TType&         fieldType,
                                        uint16_t&      fieldId)    const = 0;
   
-  virtual uint32_t readFieldEnd       (TTransport*    in)         const = 0;
+  virtual uint32_t readFieldEnd       (shared_ptr<TTransport>    in)         const = 0;
  
-  virtual uint32_t readMapBegin       (TTransport*    in,
+  virtual uint32_t readMapBegin       (shared_ptr<TTransport>    in,
                                        TType&         keyType,
                                        TType&         valType,
                                        int32_t&       size)       const = 0;
 
-  virtual uint32_t readMapEnd         (TTransport*    in)         const = 0;
+  virtual uint32_t readMapEnd         (shared_ptr<TTransport>    in)         const = 0;
 
-  virtual uint32_t readListBegin      (TTransport*    in,
+  virtual uint32_t readListBegin      (shared_ptr<TTransport>    in,
                                        TType&         elemType,
                                        int32_t&       size)       const = 0;
 
-  virtual uint32_t readListEnd        (TTransport*    in)         const = 0;
+  virtual uint32_t readListEnd        (shared_ptr<TTransport>    in)         const = 0;
 
-  virtual uint32_t readSetBegin       (TTransport*    in,
+  virtual uint32_t readSetBegin       (shared_ptr<TTransport>    in,
                                        TType&         elemType,
                                        int32_t&       size)       const = 0;
 
-  virtual uint32_t readSetEnd         (TTransport*    in)         const = 0;
+  virtual uint32_t readSetEnd         (shared_ptr<TTransport>    in)         const = 0;
 
-  virtual uint32_t readByte           (TTransport*    in,
+  virtual uint32_t readByte           (shared_ptr<TTransport>    in,
                                        uint8_t&       byte)       const = 0;
 
-  virtual uint32_t readU32            (TTransport*    in,
+  virtual uint32_t readU32            (shared_ptr<TTransport>    in,
                                        uint32_t&      u32)        const = 0;
 
-  virtual uint32_t readI32            (TTransport*    in,
+  virtual uint32_t readI32            (shared_ptr<TTransport>    in,
                                        int32_t&       i32)        const = 0;
 
-  virtual uint32_t readU64            (TTransport*    in,
+  virtual uint32_t readU64            (shared_ptr<TTransport>    in,
                                        uint64_t&      u64)        const = 0;
 
-  virtual uint32_t readI64            (TTransport*    in,
+  virtual uint32_t readI64            (shared_ptr<TTransport>    in,
                                        int64_t&       i64)        const = 0;
 
-  virtual uint32_t readString         (TTransport*    in,
+  virtual uint32_t readString         (shared_ptr<TTransport>    in,
                                        std::string&   str)        const = 0;
 
   /**
    * Method to arbitrarily skip over data.
    */
-  uint32_t skip(TTransport* in, TType type) const {
+  uint32_t skip(shared_ptr<TTransport> in, TType type) const {
     switch (type) {
     case T_BYTE:
       {
diff --git a/lib/cpp/src/protocol/protocol.txt b/lib/cpp/src/protocol/protocol.txt
index d6db0ab..d66b7eb 100644
--- a/lib/cpp/src/protocol/protocol.txt
+++ b/lib/cpp/src/protocol/protocol.txt
@@ -25,13 +25,7 @@
      package-name :		STRING
      service-name :		STRING
 
-     arguments :  		ARGS_b arg-list ARGS_e
-     arg-list :    		arg-list arg | NIL
-     arg :     			ARG_b arg-identifier arg-value ARG_e
-     arg-identifier : 		arg-name | arg-id | arg-name arg-id
-     arg-name :			STRING
-     arg-id : 			UINT32
-     arg-value :		datum
+     arguments :  		struct-datum
 
 """ service function reply message body """
 
@@ -79,16 +73,10 @@
 
 """ collection datum """
 
-     collection-type-specifier : ARRAY | MAP | SET | LIST
+     collection-type-specifier : MAP | SET | LIST
 
      collection-datum :		list-datum | set-datum | map-datum
 
-     array-datum :    		simple-array-datum | complex-array-datum
-
-     simple-array-datum :	ARRAY_b element-count simple-type-specifier simple-data ARRAY_e
-
-     complex-array-datum :	ARRAY_b element-count simple-type-specifier simple-data ARRAY_e
-
      list-datum :     		LIST_b element-count element-type-specifier elements LIST_e
 
      element-count :		UINT32