airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [07/47] Added c++ client samples for integrattion of airavata with any other application's c++ interface
Date Sat, 12 Jul 2014 04:08:25 GMT
http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocol.h
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocol.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocol.h
new file mode 100644
index 0000000..d6ecc0f
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocol.h
@@ -0,0 +1,697 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef _THRIFT_PROTOCOL_TPROTOCOL_H_
+#define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1
+
+#include <thrift/transport/TTransport.h>
+#include <thrift/protocol/TProtocolException.h>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/static_assert.hpp>
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#include <sys/types.h>
+#include <string>
+#include <map>
+#include <vector>
+
+
+// Use this to get around strict aliasing rules.
+// For example, uint64_t i = bitwise_cast<uint64_t>(returns_double());
+// The most obvious implementation is to just cast a pointer,
+// but that doesn't work.
+// For a pretty in-depth explanation of the problem, see
+// http://www.cellperformance.com/mike_acton/2006/06/ (...)
+// understanding_strict_aliasing.html
+template <typename To, typename From>
+static inline To bitwise_cast(From from) {
+  BOOST_STATIC_ASSERT(sizeof(From) == sizeof(To));
+
+  // BAD!!!  These are all broken with -O2.
+  //return *reinterpret_cast<To*>(&from);  // BAD!!!
+  //return *static_cast<To*>(static_cast<void*>(&from));  // BAD!!!
+  //return *(To*)(void*)&from;  // BAD!!!
+
+  // Super clean and paritally blessed by section 3.9 of the standard.
+  //unsigned char c[sizeof(from)];
+  //memcpy(c, &from, sizeof(from));
+  //To to;
+  //memcpy(&to, c, sizeof(c));
+  //return to;
+
+  // Slightly more questionable.
+  // Same code emitted by GCC.
+  //To to;
+  //memcpy(&to, &from, sizeof(from));
+  //return to;
+
+  // Technically undefined, but almost universally supported,
+  // and the most efficient implementation.
+  union {
+    From f;
+    To t;
+  } u;
+  u.f = from;
+  return u.t;
+}
+
+
+namespace apache { namespace thrift { namespace protocol {
+
+using apache::thrift::transport::TTransport;
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#ifndef __THRIFT_BYTE_ORDER
+# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
+#  define __THRIFT_BYTE_ORDER BYTE_ORDER
+#  define __THRIFT_LITTLE_ENDIAN LITTLE_ENDIAN
+#  define __THRIFT_BIG_ENDIAN BIG_ENDIAN
+# else
+#  include <boost/config.hpp>
+#  include <boost/detail/endian.hpp>
+#  define __THRIFT_BYTE_ORDER BOOST_BYTE_ORDER
+#  ifdef BOOST_LITTLE_ENDIAN
+#   define __THRIFT_LITTLE_ENDIAN __THRIFT_BYTE_ORDER
+#   define __THRIFT_BIG_ENDIAN 0
+#  else
+#   define __THRIFT_LITTLE_ENDIAN 0
+#   define __THRIFT_BIG_ENDIAN __THRIFT_BYTE_ORDER
+#  endif
+# endif
+#endif
+
+#if __THRIFT_BYTE_ORDER == __THRIFT_BIG_ENDIAN
+#  define ntohll(n) (n)
+#  define htonll(n) (n)
+# if defined(__GNUC__) && defined(__GLIBC__)
+#  include <byteswap.h>
+#  define htolell(n) bswap_64(n)
+#  define letohll(n) bswap_64(n)
+# else /* GNUC & GLIBC */
+#  define bswap_64(n) \
+      ( (((n) & 0xff00000000000000ull) >> 56) \
+      | (((n) & 0x00ff000000000000ull) >> 40) \
+      | (((n) & 0x0000ff0000000000ull) >> 24) \
+      | (((n) & 0x000000ff00000000ull) >> 8)  \
+      | (((n) & 0x00000000ff000000ull) << 8)  \
+      | (((n) & 0x0000000000ff0000ull) << 24) \
+      | (((n) & 0x000000000000ff00ull) << 40) \
+      | (((n) & 0x00000000000000ffull) << 56) )
+#  define htolell(n) bswap_64(n)
+#  define letohll(n) bswap_64(n)
+# endif /* GNUC & GLIBC */
+#elif __THRIFT_BYTE_ORDER == __THRIFT_LITTLE_ENDIAN
+#  define htolell(n) (n)
+#  define letohll(n) (n)
+# if defined(__GNUC__) && defined(__GLIBC__)
+#  include <byteswap.h>
+#  define ntohll(n) bswap_64(n)
+#  define htonll(n) bswap_64(n)
+# elif defined(_MSC_VER) /* Microsoft Visual C++ */
+#  define ntohll(n) ( _byteswap_uint64((uint64_t)n) )
+#  define htonll(n) ( _byteswap_uint64((uint64_t)n) )
+# else /* Not GNUC/GLIBC or MSVC */
+#  define ntohll(n) ( (((uint64_t)ntohl((uint32_t)n)) << 32) + ntohl((uint32_t)(n >> 32)) )
+#  define htonll(n) ( (((uint64_t)htonl((uint32_t)n)) << 32) + htonl((uint32_t)(n >> 32)) )
+# endif /* GNUC/GLIBC or MSVC or something else */
+#else /* __THRIFT_BYTE_ORDER */
+# error "Can't define htonll or ntohll!"
+#endif
+
+/**
+ * Enumerated definition of the types that the Thrift protocol supports.
+ * Take special note of the T_END type which is used specifically to mark
+ * the end of a sequence of fields.
+ */
+enum TType {
+  T_STOP       = 0,
+  T_VOID       = 1,
+  T_BOOL       = 2,
+  T_BYTE       = 3,
+  T_I08        = 3,
+  T_I16        = 6,
+  T_I32        = 8,
+  T_U64        = 9,
+  T_I64        = 10,
+  T_DOUBLE     = 4,
+  T_STRING     = 11,
+  T_UTF7       = 11,
+  T_STRUCT     = 12,
+  T_MAP        = 13,
+  T_SET        = 14,
+  T_LIST       = 15,
+  T_UTF8       = 16,
+  T_UTF16      = 17
+};
+
+/**
+ * Enumerated definition of the message types that the Thrift protocol
+ * supports.
+ */
+enum TMessageType {
+  T_CALL       = 1,
+  T_REPLY      = 2,
+  T_EXCEPTION  = 3,
+  T_ONEWAY     = 4
+};
+
+
+/**
+ * Helper template for implementing TProtocol::skip().
+ *
+ * Templatized to avoid having to make virtual function calls.
+ */
+template <class Protocol_>
+uint32_t skip(Protocol_& prot, TType type) {
+  switch (type) {
+  case T_BOOL:
+    {
+      bool boolv;
+      return prot.readBool(boolv);
+    }
+  case T_BYTE:
+    {
+      int8_t bytev;
+      return prot.readByte(bytev);
+    }
+  case T_I16:
+    {
+      int16_t i16;
+      return prot.readI16(i16);
+    }
+  case T_I32:
+    {
+      int32_t i32;
+      return prot.readI32(i32);
+    }
+  case T_I64:
+    {
+      int64_t i64;
+      return prot.readI64(i64);
+    }
+  case T_DOUBLE:
+    {
+      double dub;
+      return prot.readDouble(dub);
+    }
+  case T_STRING:
+    {
+      std::string str;
+      return prot.readBinary(str);
+    }
+  case T_STRUCT:
+    {
+      uint32_t result = 0;
+      std::string name;
+      int16_t fid;
+      TType ftype;
+      result += prot.readStructBegin(name);
+      while (true) {
+        result += prot.readFieldBegin(name, ftype, fid);
+        if (ftype == T_STOP) {
+          break;
+        }
+        result += skip(prot, ftype);
+        result += prot.readFieldEnd();
+      }
+      result += prot.readStructEnd();
+      return result;
+    }
+  case T_MAP:
+    {
+      uint32_t result = 0;
+      TType keyType;
+      TType valType;
+      uint32_t i, size;
+      result += prot.readMapBegin(keyType, valType, size);
+      for (i = 0; i < size; i++) {
+        result += skip(prot, keyType);
+        result += skip(prot, valType);
+      }
+      result += prot.readMapEnd();
+      return result;
+    }
+  case T_SET:
+    {
+      uint32_t result = 0;
+      TType elemType;
+      uint32_t i, size;
+      result += prot.readSetBegin(elemType, size);
+      for (i = 0; i < size; i++) {
+        result += skip(prot, elemType);
+      }
+      result += prot.readSetEnd();
+      return result;
+    }
+  case T_LIST:
+    {
+      uint32_t result = 0;
+      TType elemType;
+      uint32_t i, size;
+      result += prot.readListBegin(elemType, size);
+      for (i = 0; i < size; i++) {
+        result += skip(prot, elemType);
+      }
+      result += prot.readListEnd();
+      return result;
+    }
+  case T_STOP: case T_VOID: case T_U64: case T_UTF8: case T_UTF16:
+    break;
+  }
+  return 0;
+}
+
+/**
+ * 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
+ * with indexed fields.
+ *
+ * TProtocol objects should not be shared across multiple encoding contexts,
+ * as they may need to maintain internal state in some protocols (i.e. XML).
+ * Note that is is acceptable for the TProtocol module to do its own internal
+ * buffered reads/writes to the underlying TTransport where appropriate (i.e.
+ * when parsing an input XML stream, reading should be batched rather than
+ * looking ahead character by character for a close tag).
+ *
+ */
+class TProtocol {
+ public:
+  virtual ~TProtocol() {}
+
+  /**
+   * Writing functions.
+   */
+
+  virtual uint32_t writeMessageBegin_virt(const std::string& name,
+                                          const TMessageType messageType,
+                                          const int32_t seqid) = 0;
+
+  virtual uint32_t writeMessageEnd_virt() = 0;
+
+
+  virtual uint32_t writeStructBegin_virt(const char* name) = 0;
+
+  virtual uint32_t writeStructEnd_virt() = 0;
+
+  virtual uint32_t writeFieldBegin_virt(const char* name,
+                                        const TType fieldType,
+                                        const int16_t fieldId) = 0;
+
+  virtual uint32_t writeFieldEnd_virt() = 0;
+
+  virtual uint32_t writeFieldStop_virt() = 0;
+
+  virtual uint32_t writeMapBegin_virt(const TType keyType,
+                                      const TType valType,
+                                      const uint32_t size) = 0;
+
+  virtual uint32_t writeMapEnd_virt() = 0;
+
+  virtual uint32_t writeListBegin_virt(const TType elemType,
+                                       const uint32_t size) = 0;
+
+  virtual uint32_t writeListEnd_virt() = 0;
+
+  virtual uint32_t writeSetBegin_virt(const TType elemType,
+                                      const uint32_t size) = 0;
+
+  virtual uint32_t writeSetEnd_virt() = 0;
+
+  virtual uint32_t writeBool_virt(const bool value) = 0;
+
+  virtual uint32_t writeByte_virt(const int8_t byte) = 0;
+
+  virtual uint32_t writeI16_virt(const int16_t i16) = 0;
+
+  virtual uint32_t writeI32_virt(const int32_t i32) = 0;
+
+  virtual uint32_t writeI64_virt(const int64_t i64) = 0;
+
+  virtual uint32_t writeDouble_virt(const double dub) = 0;
+
+  virtual uint32_t writeString_virt(const std::string& str) = 0;
+
+  virtual uint32_t writeBinary_virt(const std::string& str) = 0;
+
+  uint32_t writeMessageBegin(const std::string& name,
+                             const TMessageType messageType,
+                             const int32_t seqid) {
+    T_VIRTUAL_CALL();
+    return writeMessageBegin_virt(name, messageType, seqid);
+  }
+
+  uint32_t writeMessageEnd() {
+    T_VIRTUAL_CALL();
+    return writeMessageEnd_virt();
+  }
+
+
+  uint32_t writeStructBegin(const char* name) {
+    T_VIRTUAL_CALL();
+    return writeStructBegin_virt(name);
+  }
+
+  uint32_t writeStructEnd() {
+    T_VIRTUAL_CALL();
+    return writeStructEnd_virt();
+  }
+
+  uint32_t writeFieldBegin(const char* name,
+                           const TType fieldType,
+                           const int16_t fieldId) {
+    T_VIRTUAL_CALL();
+    return writeFieldBegin_virt(name, fieldType, fieldId);
+  }
+
+  uint32_t writeFieldEnd() {
+    T_VIRTUAL_CALL();
+    return writeFieldEnd_virt();
+  }
+
+  uint32_t writeFieldStop() {
+    T_VIRTUAL_CALL();
+    return writeFieldStop_virt();
+  }
+
+  uint32_t writeMapBegin(const TType keyType,
+                         const TType valType,
+                         const uint32_t size) {
+    T_VIRTUAL_CALL();
+    return writeMapBegin_virt(keyType, valType, size);
+  }
+
+  uint32_t writeMapEnd() {
+    T_VIRTUAL_CALL();
+    return writeMapEnd_virt();
+  }
+
+  uint32_t writeListBegin(const TType elemType, const uint32_t size) {
+    T_VIRTUAL_CALL();
+    return writeListBegin_virt(elemType, size);
+  }
+
+  uint32_t writeListEnd() {
+    T_VIRTUAL_CALL();
+    return writeListEnd_virt();
+  }
+
+  uint32_t writeSetBegin(const TType elemType, const uint32_t size) {
+    T_VIRTUAL_CALL();
+    return writeSetBegin_virt(elemType, size);
+  }
+
+  uint32_t writeSetEnd() {
+    T_VIRTUAL_CALL();
+    return writeSetEnd_virt();
+  }
+
+  uint32_t writeBool(const bool value) {
+    T_VIRTUAL_CALL();
+    return writeBool_virt(value);
+  }
+
+  uint32_t writeByte(const int8_t byte) {
+    T_VIRTUAL_CALL();
+    return writeByte_virt(byte);
+  }
+
+  uint32_t writeI16(const int16_t i16) {
+    T_VIRTUAL_CALL();
+    return writeI16_virt(i16);
+  }
+
+  uint32_t writeI32(const int32_t i32) {
+    T_VIRTUAL_CALL();
+    return writeI32_virt(i32);
+  }
+
+  uint32_t writeI64(const int64_t i64) {
+    T_VIRTUAL_CALL();
+    return writeI64_virt(i64);
+  }
+
+  uint32_t writeDouble(const double dub) {
+    T_VIRTUAL_CALL();
+    return writeDouble_virt(dub);
+  }
+
+  uint32_t writeString(const std::string& str) {
+    T_VIRTUAL_CALL();
+    return writeString_virt(str);
+  }
+
+  uint32_t writeBinary(const std::string& str) {
+    T_VIRTUAL_CALL();
+    return writeBinary_virt(str);
+  }
+
+  /**
+   * Reading functions
+   */
+
+  virtual uint32_t readMessageBegin_virt(std::string& name,
+                                         TMessageType& messageType,
+                                         int32_t& seqid) = 0;
+
+  virtual uint32_t readMessageEnd_virt() = 0;
+
+  virtual uint32_t readStructBegin_virt(std::string& name) = 0;
+
+  virtual uint32_t readStructEnd_virt() = 0;
+
+  virtual uint32_t readFieldBegin_virt(std::string& name,
+                                       TType& fieldType,
+                                       int16_t& fieldId) = 0;
+
+  virtual uint32_t readFieldEnd_virt() = 0;
+
+  virtual uint32_t readMapBegin_virt(TType& keyType,
+                                     TType& valType,
+                                     uint32_t& size) = 0;
+
+  virtual uint32_t readMapEnd_virt() = 0;
+
+  virtual uint32_t readListBegin_virt(TType& elemType,
+                                      uint32_t& size) = 0;
+
+  virtual uint32_t readListEnd_virt() = 0;
+
+  virtual uint32_t readSetBegin_virt(TType& elemType,
+                                     uint32_t& size) = 0;
+
+  virtual uint32_t readSetEnd_virt() = 0;
+
+  virtual uint32_t readBool_virt(bool& value) = 0;
+
+  virtual uint32_t readBool_virt(std::vector<bool>::reference value) = 0;
+
+  virtual uint32_t readByte_virt(int8_t& byte) = 0;
+
+  virtual uint32_t readI16_virt(int16_t& i16) = 0;
+
+  virtual uint32_t readI32_virt(int32_t& i32) = 0;
+
+  virtual uint32_t readI64_virt(int64_t& i64) = 0;
+
+  virtual uint32_t readDouble_virt(double& dub) = 0;
+
+  virtual uint32_t readString_virt(std::string& str) = 0;
+
+  virtual uint32_t readBinary_virt(std::string& str) = 0;
+
+  uint32_t readMessageBegin(std::string& name,
+                            TMessageType& messageType,
+                            int32_t& seqid) {
+    T_VIRTUAL_CALL();
+    return readMessageBegin_virt(name, messageType, seqid);
+  }
+
+  uint32_t readMessageEnd() {
+    T_VIRTUAL_CALL();
+    return readMessageEnd_virt();
+  }
+
+  uint32_t readStructBegin(std::string& name) {
+    T_VIRTUAL_CALL();
+    return readStructBegin_virt(name);
+  }
+
+  uint32_t readStructEnd() {
+    T_VIRTUAL_CALL();
+    return readStructEnd_virt();
+  }
+
+  uint32_t readFieldBegin(std::string& name,
+                          TType& fieldType,
+                          int16_t& fieldId) {
+    T_VIRTUAL_CALL();
+    return readFieldBegin_virt(name, fieldType, fieldId);
+  }
+
+  uint32_t readFieldEnd() {
+    T_VIRTUAL_CALL();
+    return readFieldEnd_virt();
+  }
+
+  uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
+    T_VIRTUAL_CALL();
+    return readMapBegin_virt(keyType, valType, size);
+  }
+
+  uint32_t readMapEnd() {
+    T_VIRTUAL_CALL();
+    return readMapEnd_virt();
+  }
+
+  uint32_t readListBegin(TType& elemType, uint32_t& size) {
+    T_VIRTUAL_CALL();
+    return readListBegin_virt(elemType, size);
+  }
+
+  uint32_t readListEnd() {
+    T_VIRTUAL_CALL();
+    return readListEnd_virt();
+  }
+
+  uint32_t readSetBegin(TType& elemType, uint32_t& size) {
+    T_VIRTUAL_CALL();
+    return readSetBegin_virt(elemType, size);
+  }
+
+  uint32_t readSetEnd() {
+    T_VIRTUAL_CALL();
+    return readSetEnd_virt();
+  }
+
+  uint32_t readBool(bool& value) {
+    T_VIRTUAL_CALL();
+    return readBool_virt(value);
+  }
+
+  uint32_t readByte(int8_t& byte) {
+    T_VIRTUAL_CALL();
+    return readByte_virt(byte);
+  }
+
+  uint32_t readI16(int16_t& i16) {
+    T_VIRTUAL_CALL();
+    return readI16_virt(i16);
+  }
+
+  uint32_t readI32(int32_t& i32) {
+    T_VIRTUAL_CALL();
+    return readI32_virt(i32);
+  }
+
+  uint32_t readI64(int64_t& i64) {
+    T_VIRTUAL_CALL();
+    return readI64_virt(i64);
+  }
+
+  uint32_t readDouble(double& dub) {
+    T_VIRTUAL_CALL();
+    return readDouble_virt(dub);
+  }
+
+  uint32_t readString(std::string& str) {
+    T_VIRTUAL_CALL();
+    return readString_virt(str);
+  }
+
+  uint32_t readBinary(std::string& str) {
+    T_VIRTUAL_CALL();
+    return readBinary_virt(str);
+  }
+
+  /*
+   * std::vector is specialized for bool, and its elements are individual bits
+   * rather than bools.   We need to define a different version of readBool()
+   * to work with std::vector<bool>.
+   */
+  uint32_t readBool(std::vector<bool>::reference value) {
+    T_VIRTUAL_CALL();
+    return readBool_virt(value);
+  }
+
+  /**
+   * Method to arbitrarily skip over data.
+   */
+  uint32_t skip(TType type) {
+    T_VIRTUAL_CALL();
+    return skip_virt(type);
+  }
+  virtual uint32_t skip_virt(TType type) {
+    return ::apache::thrift::protocol::skip(*this, type);
+  }
+
+  inline boost::shared_ptr<TTransport> getTransport() {
+    return ptrans_;
+  }
+
+  // TODO: remove these two calls, they are for backwards
+  // compatibility
+  inline boost::shared_ptr<TTransport> getInputTransport() {
+    return ptrans_;
+  }
+  inline boost::shared_ptr<TTransport> getOutputTransport() {
+    return ptrans_;
+  }
+
+ protected:
+  TProtocol(boost::shared_ptr<TTransport> ptrans):
+    ptrans_(ptrans) {
+  }
+
+  boost::shared_ptr<TTransport> ptrans_;
+
+ private:
+  TProtocol() {}
+};
+
+/**
+ * Constructs input and output protocol objects given transports.
+ */
+class TProtocolFactory {
+ public:
+  TProtocolFactory() {}
+
+  virtual ~TProtocolFactory() {}
+
+  virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) = 0;
+};
+
+/**
+ * Dummy protocol class.
+ *
+ * This class does nothing, and should never be instantiated.
+ * It is used only by the generator code.
+ */
+class TDummyProtocol : public TProtocol {
+};
+
+}}} // apache::thrift::protocol
+
+#endif // #define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolDecorator.h
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolDecorator.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolDecorator.h
new file mode 100644
index 0000000..7850bc5
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolDecorator.h
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef THRIFT_TPROTOCOLDECORATOR_H_
+#define THRIFT_TPROTOCOLDECORATOR_H_ 1
+
+#include <thrift/protocol/TProtocol.h>
+#include <boost/shared_ptr.hpp>
+
+namespace apache 
+{ 
+    namespace thrift 
+    { 
+        namespace protocol 
+        {
+            using boost::shared_ptr;
+
+            /**
+             * <code>TProtocolDecorator</code> forwards all requests to an enclosed
+             * <code>TProtocol</code> instance, providing a way to author concise
+             * concrete decorator subclasses.  
+             *
+             * <p>See p.175 of Design Patterns (by Gamma et al.)</p>
+             * 
+             * @see apache::thrift::protocol::TMultiplexedProtocol
+             */
+            class TProtocolDecorator : public TProtocol
+            {
+            public:
+                virtual ~TProtocolDecorator() {}
+                
+                // Desc: Initializes the protocol decorator object.
+                TProtocolDecorator( shared_ptr<TProtocol> proto ) 
+                    : TProtocol(proto->getTransport()), protocol(proto)
+                {
+                }
+
+                virtual uint32_t writeMessageBegin_virt(
+                    const std::string& name, 
+                    const TMessageType messageType, 
+                    const int32_t seqid)
+                {
+                    return protocol->writeMessageBegin(name, messageType, seqid); 
+                }
+                virtual uint32_t writeMessageEnd_virt() { return protocol->writeMessageEnd(); }
+                virtual uint32_t writeStructBegin_virt(const char* name) { return protocol->writeStructBegin(name); }
+                virtual uint32_t writeStructEnd_virt() { return protocol->writeStructEnd(); }
+
+                virtual uint32_t writeFieldBegin_virt(const char* name,
+                    const TType fieldType,
+                    const int16_t fieldId) { return protocol->writeFieldBegin(name,fieldType,fieldId); }
+
+                virtual uint32_t writeFieldEnd_virt()  { return protocol->writeFieldEnd(); }
+                virtual uint32_t writeFieldStop_virt() { return protocol->writeFieldStop(); }
+
+                virtual uint32_t writeMapBegin_virt(const TType keyType,
+                    const TType valType,
+                    const uint32_t size) { return protocol->writeMapBegin(keyType,valType,size); }
+
+                virtual uint32_t writeMapEnd_virt() { return protocol->writeMapEnd(); }
+
+                virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeListBegin(elemType,size); }
+                virtual uint32_t writeListEnd_virt() { return protocol->writeListEnd(); }
+
+                virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeSetBegin(elemType,size); }
+                virtual uint32_t writeSetEnd_virt() { return protocol->writeSetEnd(); }
+
+                virtual uint32_t writeBool_virt(const bool value)  { return protocol->writeBool(value); }
+                virtual uint32_t writeByte_virt(const int8_t byte) { return protocol->writeByte(byte); }
+                virtual uint32_t writeI16_virt(const int16_t i16)  { return protocol->writeI16(i16); }
+                virtual uint32_t writeI32_virt(const int32_t i32)  { return protocol->writeI32(i32); }
+                virtual uint32_t writeI64_virt(const int64_t i64)  { return protocol->writeI64(i64); }
+
+                virtual uint32_t writeDouble_virt(const double dub) { return protocol->writeDouble(dub); }
+                virtual uint32_t writeString_virt(const std::string& str) { return protocol->writeString(str); }
+                virtual uint32_t writeBinary_virt(const std::string& str) { return protocol->writeBinary(str); }
+
+                virtual uint32_t readMessageBegin_virt(std::string& name, TMessageType& messageType, int32_t& seqid) { return protocol->readMessageBegin(name,messageType,seqid); }
+                virtual uint32_t readMessageEnd_virt() { return protocol->readMessageEnd(); }
+
+                virtual uint32_t readStructBegin_virt(std::string& name) { return protocol->readStructBegin(name); }
+                virtual uint32_t readStructEnd_virt() { return protocol->readStructEnd(); }
+
+                virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) { return protocol->readFieldBegin(name, fieldType, fieldId); }
+                virtual uint32_t readFieldEnd_virt() { return protocol->readFieldEnd(); }
+
+                virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) { return protocol->readMapBegin(keyType,valType,size); }
+                virtual uint32_t readMapEnd_virt() { return protocol->readMapEnd(); }
+
+                virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) { return protocol->readListBegin(elemType,size); }
+                virtual uint32_t readListEnd_virt() { return protocol->readListEnd(); }
+
+                virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) { return protocol->readSetBegin(elemType,size); }
+                virtual uint32_t readSetEnd_virt() { return protocol->readSetEnd(); }
+
+                virtual uint32_t readBool_virt(bool& value) { return protocol->readBool(value); }
+                virtual uint32_t readBool_virt(std::vector<bool>::reference value) { return protocol->readBool(value); }
+                
+                virtual uint32_t readByte_virt(int8_t& byte) { return protocol->readByte(byte); }
+
+                virtual uint32_t readI16_virt(int16_t& i16) { return protocol->readI16(i16); }
+                virtual uint32_t readI32_virt(int32_t& i32) { return protocol->readI32(i32); }
+                virtual uint32_t readI64_virt(int64_t& i64) { return protocol->readI64(i64); }
+
+                virtual uint32_t readDouble_virt(double& dub) { return protocol->readDouble(dub); }
+
+                virtual uint32_t readString_virt(std::string& str) { return protocol->readString(str); }
+                virtual uint32_t readBinary_virt(std::string& str) { return protocol->readBinary(str); }
+
+            private:
+                shared_ptr<TProtocol> protocol;    
+            };
+        }
+    }
+} 
+
+#endif // THRIFT_TPROTOCOLDECORATOR_H_

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolException.h
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolException.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolException.h
new file mode 100644
index 0000000..a03d3c8
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolException.h
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_
+#define _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_ 1
+
+#include <string>
+
+namespace apache { namespace thrift { namespace protocol {
+
+/**
+ * Class to encapsulate all the possible types of protocol errors that may
+ * occur in various protocol systems. This provides a sort of generic
+ * wrapper around the vague UNIX E_ error codes that lets a common code
+ * base of error handling to be used for various types of protocols, i.e.
+ * pipes etc.
+ *
+ */
+class TProtocolException : public apache::thrift::TException {
+ public:
+
+  /**
+   * Error codes for the various types of exceptions.
+   */
+  enum TProtocolExceptionType
+  { UNKNOWN = 0
+  , INVALID_DATA = 1
+  , NEGATIVE_SIZE = 2
+  , SIZE_LIMIT = 3
+  , BAD_VERSION = 4
+  , NOT_IMPLEMENTED = 5
+  };
+
+  TProtocolException() :
+    apache::thrift::TException(),
+    type_(UNKNOWN) {}
+
+  TProtocolException(TProtocolExceptionType type) :
+    apache::thrift::TException(),
+    type_(type) {}
+
+  TProtocolException(const std::string& message) :
+    apache::thrift::TException(message),
+    type_(UNKNOWN) {}
+
+  TProtocolException(TProtocolExceptionType type, const std::string& message) :
+    apache::thrift::TException(message),
+    type_(type) {}
+
+  virtual ~TProtocolException() throw() {}
+
+  /**
+   * Returns an error code that provides information about the type of error
+   * that has occurred.
+   *
+   * @return Error code
+   */
+  TProtocolExceptionType getType() {
+    return type_;
+  }
+
+  virtual const char* what() const throw() {
+    if (message_.empty()) {
+      switch (type_) {
+        case UNKNOWN         : return "TProtocolException: Unknown protocol exception";
+        case INVALID_DATA    : return "TProtocolException: Invalid data";
+        case NEGATIVE_SIZE   : return "TProtocolException: Negative size";
+        case SIZE_LIMIT      : return "TProtocolException: Exceeded size limit";
+        case BAD_VERSION     : return "TProtocolException: Invalid version";
+        case NOT_IMPLEMENTED : return "TProtocolException: Not implemented";
+        default              : return "TProtocolException: (Invalid exception type)";
+      }
+    } else {
+      return message_.c_str();
+    }
+  }
+
+ protected:
+  /**
+   * Error code
+   */
+  TProtocolExceptionType type_;
+
+};
+
+}}} // apache::thrift::protocol
+
+#endif // #ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolTap.h
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolTap.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolTap.h
new file mode 100644
index 0000000..f493f88
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TProtocolTap.h
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef _THRIFT_PROTOCOL_TPROTOCOLTAP_H_
+#define _THRIFT_PROTOCOL_TPROTOCOLTAP_H_ 1
+
+#include <thrift/protocol/TVirtualProtocol.h>
+
+namespace apache { namespace thrift { namespace protocol {
+
+using apache::thrift::transport::TTransport;
+
+/**
+ * Puts a wiretap on a protocol object.  Any reads to this class are passed
+ * through to an enclosed protocol object, but also mirrored as write to a
+ * second protocol object.
+ *
+ */
+class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
+ public:
+   TProtocolTap(boost::shared_ptr<TProtocol> source,
+                boost::shared_ptr<TProtocol> sink)
+     : TVirtualProtocol<TProtocolTap>(source->getTransport())
+     , source_(source)
+     , sink_(sink)
+  {}
+
+  uint32_t readMessageBegin(std::string& name,
+                            TMessageType& messageType,
+                            int32_t& seqid) {
+    uint32_t rv = source_->readMessageBegin(name, messageType, seqid);
+    sink_->writeMessageBegin(name, messageType, seqid);
+    return rv;
+  }
+
+  uint32_t readMessageEnd() {
+    uint32_t rv = source_->readMessageEnd();
+    sink_->writeMessageEnd();
+    return rv;
+  }
+
+  uint32_t readStructBegin(std::string& name) {
+    uint32_t rv = source_->readStructBegin(name);
+    sink_->writeStructBegin(name.c_str());
+    return rv;
+  }
+
+  uint32_t readStructEnd() {
+    uint32_t rv = source_->readStructEnd();
+    sink_->writeStructEnd();
+    return rv;
+  }
+
+  uint32_t readFieldBegin(std::string& name,
+                          TType& fieldType,
+                          int16_t& fieldId) {
+    uint32_t rv = source_->readFieldBegin(name, fieldType, fieldId);
+    if (fieldType == T_STOP) {
+      sink_->writeFieldStop();
+    } else {
+      sink_->writeFieldBegin(name.c_str(), fieldType, fieldId);
+    }
+    return rv;
+  }
+
+
+  uint32_t readFieldEnd() {
+    uint32_t rv = source_->readFieldEnd();
+    sink_->writeFieldEnd();
+    return rv;
+  }
+
+  uint32_t readMapBegin(TType& keyType,
+                        TType& valType,
+                        uint32_t& size) {
+    uint32_t rv = source_->readMapBegin(keyType, valType, size);
+    sink_->writeMapBegin(keyType, valType, size);
+    return rv;
+  }
+
+
+  uint32_t readMapEnd() {
+    uint32_t rv = source_->readMapEnd();
+    sink_->writeMapEnd();
+    return rv;
+  }
+
+  uint32_t readListBegin(TType& elemType, uint32_t& size) {
+    uint32_t rv = source_->readListBegin(elemType, size);
+    sink_->writeListBegin(elemType, size);
+    return rv;
+  }
+
+
+  uint32_t readListEnd() {
+    uint32_t rv = source_->readListEnd();
+    sink_->writeListEnd();
+    return rv;
+  }
+
+  uint32_t readSetBegin(TType& elemType, uint32_t& size) {
+    uint32_t rv = source_->readSetBegin(elemType, size);
+    sink_->writeSetBegin(elemType, size);
+    return rv;
+  }
+
+
+  uint32_t readSetEnd() {
+    uint32_t rv = source_->readSetEnd();
+    sink_->writeSetEnd();
+    return rv;
+  }
+
+  uint32_t readBool(bool& value) {
+    uint32_t rv = source_->readBool(value);
+    sink_->writeBool(value);
+    return rv;
+  }
+
+  // Provide the default readBool() implementation for std::vector<bool>
+  using TVirtualProtocol<TProtocolTap>::readBool;
+
+  uint32_t readByte(int8_t& byte) {
+    uint32_t rv = source_->readByte(byte);
+    sink_->writeByte(byte);
+    return rv;
+  }
+
+  uint32_t readI16(int16_t& i16) {
+    uint32_t rv = source_->readI16(i16);
+    sink_->writeI16(i16);
+    return rv;
+  }
+
+  uint32_t readI32(int32_t& i32) {
+    uint32_t rv = source_->readI32(i32);
+    sink_->writeI32(i32);
+    return rv;
+  }
+
+  uint32_t readI64(int64_t& i64) {
+    uint32_t rv = source_->readI64(i64);
+    sink_->writeI64(i64);
+    return rv;
+  }
+
+  uint32_t readDouble(double& dub) {
+    uint32_t rv = source_->readDouble(dub);
+    sink_->writeDouble(dub);
+    return rv;
+  }
+
+  uint32_t readString(std::string& str) {
+    uint32_t rv = source_->readString(str);
+    sink_->writeString(str);
+    return rv;
+  }
+
+  uint32_t readBinary(std::string& str) {
+    uint32_t rv = source_->readBinary(str);
+    sink_->writeBinary(str);
+    return rv;
+  }
+
+ private:
+  boost::shared_ptr<TProtocol> source_;
+  boost::shared_ptr<TProtocol> sink_;
+};
+
+}}} // apache::thrift::protocol
+
+#endif // #define _THRIFT_PROTOCOL_TPROTOCOLTAP_H_ 1

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TVirtualProtocol.h
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TVirtualProtocol.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TVirtualProtocol.h
new file mode 100644
index 0000000..e068725
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/protocol/TVirtualProtocol.h
@@ -0,0 +1,564 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef _THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_
+#define _THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_ 1
+
+#include <thrift/protocol/TProtocol.h>
+
+namespace apache { namespace thrift { namespace protocol {
+
+using apache::thrift::transport::TTransport;
+
+/**
+ * Helper class that provides default implementations of TProtocol methods.
+ *
+ * This class provides default implementations of the non-virtual TProtocol
+ * methods.  It exists primarily so TVirtualProtocol can derive from it.  It
+ * prevents TVirtualProtocol methods from causing infinite recursion if the
+ * non-virtual methods are not overridden by the TVirtualProtocol subclass.
+ *
+ * You probably don't want to use this class directly.  Use TVirtualProtocol
+ * instead.
+ */
+class TProtocolDefaults : public TProtocol {
+ public:
+  uint32_t readMessageBegin(std::string& name,
+                            TMessageType& messageType,
+                            int32_t& seqid) {
+    (void) name;
+    (void) messageType;
+    (void) seqid;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readMessageEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readStructBegin(std::string& name) {
+    (void) name;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readStructEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readFieldBegin(std::string& name,
+                          TType& fieldType,
+                          int16_t& fieldId) {
+    (void) name;
+    (void) fieldType;
+    (void) fieldId;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readFieldEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
+    (void) keyType;
+    (void) valType;
+    (void) size;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readMapEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readListBegin(TType& elemType, uint32_t& size) {
+    (void) elemType;
+    (void) size;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readListEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readSetBegin(TType& elemType, uint32_t& size) {
+    (void) elemType;
+    (void) size;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readSetEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readBool(bool& value) {
+    (void) value;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readBool(std::vector<bool>::reference value) {
+    (void) value;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readByte(int8_t& byte) {
+    (void) byte;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readI16(int16_t& i16) {
+    (void) i16;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readI32(int32_t& i32) {
+    (void) i32;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readI64(int64_t& i64) {
+    (void) i64;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readDouble(double& dub) {
+    (void) dub;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readString(std::string& str) {
+    (void) str;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t readBinary(std::string& str) {
+    (void) str;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support reading (yet).");
+  }
+
+  uint32_t writeMessageBegin(const std::string& name,
+                             const TMessageType messageType,
+                             const int32_t seqid) {
+    (void) name;
+    (void) messageType;
+    (void) seqid;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeMessageEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+
+  uint32_t writeStructBegin(const char* name) {
+    (void) name;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeStructEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeFieldBegin(const char* name,
+                           const TType fieldType,
+                           const int16_t fieldId) {
+    (void) name;
+    (void) fieldType;
+    (void) fieldId;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeFieldEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeFieldStop() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeMapBegin(const TType keyType,
+                         const TType valType,
+                         const uint32_t size) {
+    (void) keyType;
+    (void) valType;
+    (void) size;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeMapEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeListBegin(const TType elemType, const uint32_t size) {
+    (void) elemType;
+    (void) size;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeListEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeSetBegin(const TType elemType, const uint32_t size) {
+    (void) elemType;
+    (void) size;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeSetEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeBool(const bool value) {
+    (void) value;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeByte(const int8_t byte) {
+    (void) byte;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeI16(const int16_t i16) {
+    (void) i16;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeI32(const int32_t i32) {
+    (void) i32;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeI64(const int64_t i64) {
+    (void) i64;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeDouble(const double dub) {
+    (void) dub;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeString(const std::string& str) {
+    (void) str;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t writeBinary(const std::string& str) {
+    (void) str;
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+                             "this protocol does not support writing (yet).");
+  }
+
+  uint32_t skip(TType type) {
+    return ::apache::thrift::protocol::skip(*this, type);
+  }
+
+ protected:
+  TProtocolDefaults(boost::shared_ptr<TTransport> ptrans)
+    : TProtocol(ptrans)
+  {}
+};
+
+/**
+ * Concrete TProtocol classes should inherit from TVirtualProtocol
+ * so they don't have to manually override virtual methods.
+ */
+template <class Protocol_, class Super_=TProtocolDefaults>
+class TVirtualProtocol : public Super_ {
+ public:
+  /**
+   * Writing functions.
+   */
+
+  virtual uint32_t writeMessageBegin_virt(const std::string& name,
+                                          const TMessageType messageType,
+                                          const int32_t seqid) {
+    return static_cast<Protocol_*>(this)->writeMessageBegin(name, messageType,
+                                                            seqid);
+  }
+
+  virtual uint32_t writeMessageEnd_virt() {
+    return static_cast<Protocol_*>(this)->writeMessageEnd();
+  }
+
+
+  virtual uint32_t writeStructBegin_virt(const char* name) {
+    return static_cast<Protocol_*>(this)->writeStructBegin(name);
+  }
+
+  virtual uint32_t writeStructEnd_virt() {
+    return static_cast<Protocol_*>(this)->writeStructEnd();
+  }
+
+  virtual uint32_t writeFieldBegin_virt(const char* name,
+                                        const TType fieldType,
+                                        const int16_t fieldId) {
+    return static_cast<Protocol_*>(this)->writeFieldBegin(name, fieldType,
+                                                          fieldId);
+  }
+
+  virtual uint32_t writeFieldEnd_virt() {
+    return static_cast<Protocol_*>(this)->writeFieldEnd();
+  }
+
+  virtual uint32_t writeFieldStop_virt() {
+    return static_cast<Protocol_*>(this)->writeFieldStop();
+  }
+
+  virtual uint32_t writeMapBegin_virt(const TType keyType,
+                                      const TType valType,
+                                      const uint32_t size) {
+    return static_cast<Protocol_*>(this)->writeMapBegin(keyType, valType, size);
+  }
+
+  virtual uint32_t writeMapEnd_virt() {
+    return static_cast<Protocol_*>(this)->writeMapEnd();
+  }
+
+  virtual uint32_t writeListBegin_virt(const TType elemType,
+                                       const uint32_t size) {
+    return static_cast<Protocol_*>(this)->writeListBegin(elemType, size);
+  }
+
+  virtual uint32_t writeListEnd_virt() {
+    return static_cast<Protocol_*>(this)->writeListEnd();
+  }
+
+  virtual uint32_t writeSetBegin_virt(const TType elemType,
+                                      const uint32_t size) {
+    return static_cast<Protocol_*>(this)->writeSetBegin(elemType, size);
+  }
+
+  virtual uint32_t writeSetEnd_virt() {
+    return static_cast<Protocol_*>(this)->writeSetEnd();
+  }
+
+  virtual uint32_t writeBool_virt(const bool value) {
+    return static_cast<Protocol_*>(this)->writeBool(value);
+  }
+
+  virtual uint32_t writeByte_virt(const int8_t byte) {
+    return static_cast<Protocol_*>(this)->writeByte(byte);
+  }
+
+  virtual uint32_t writeI16_virt(const int16_t i16) {
+    return static_cast<Protocol_*>(this)->writeI16(i16);
+  }
+
+  virtual uint32_t writeI32_virt(const int32_t i32) {
+    return static_cast<Protocol_*>(this)->writeI32(i32);
+  }
+
+  virtual uint32_t writeI64_virt(const int64_t i64) {
+    return static_cast<Protocol_*>(this)->writeI64(i64);
+  }
+
+  virtual uint32_t writeDouble_virt(const double dub) {
+    return static_cast<Protocol_*>(this)->writeDouble(dub);
+  }
+
+  virtual uint32_t writeString_virt(const std::string& str) {
+    return static_cast<Protocol_*>(this)->writeString(str);
+  }
+
+  virtual uint32_t writeBinary_virt(const std::string& str) {
+    return static_cast<Protocol_*>(this)->writeBinary(str);
+  }
+
+  /**
+   * Reading functions
+   */
+
+  virtual uint32_t readMessageBegin_virt(std::string& name,
+                                         TMessageType& messageType,
+                                         int32_t& seqid) {
+    return static_cast<Protocol_*>(this)->readMessageBegin(name, messageType,
+                                                           seqid);
+  }
+
+  virtual uint32_t readMessageEnd_virt() {
+    return static_cast<Protocol_*>(this)->readMessageEnd();
+  }
+
+  virtual uint32_t readStructBegin_virt(std::string& name) {
+    return static_cast<Protocol_*>(this)->readStructBegin(name);
+  }
+
+  virtual uint32_t readStructEnd_virt() {
+    return static_cast<Protocol_*>(this)->readStructEnd();
+  }
+
+  virtual uint32_t readFieldBegin_virt(std::string& name,
+                                       TType& fieldType,
+                                       int16_t& fieldId) {
+    return static_cast<Protocol_*>(this)->readFieldBegin(name, fieldType,
+                                                         fieldId);
+  }
+
+  virtual uint32_t readFieldEnd_virt() {
+    return static_cast<Protocol_*>(this)->readFieldEnd();
+  }
+
+  virtual uint32_t readMapBegin_virt(TType& keyType,
+                                     TType& valType,
+                                     uint32_t& size) {
+    return static_cast<Protocol_*>(this)->readMapBegin(keyType, valType, size);
+  }
+
+  virtual uint32_t readMapEnd_virt() {
+    return static_cast<Protocol_*>(this)->readMapEnd();
+  }
+
+  virtual uint32_t readListBegin_virt(TType& elemType,
+                                      uint32_t& size) {
+    return static_cast<Protocol_*>(this)->readListBegin(elemType, size);
+  }
+
+  virtual uint32_t readListEnd_virt() {
+    return static_cast<Protocol_*>(this)->readListEnd();
+  }
+
+  virtual uint32_t readSetBegin_virt(TType& elemType,
+                                     uint32_t& size) {
+    return static_cast<Protocol_*>(this)->readSetBegin(elemType, size);
+  }
+
+  virtual uint32_t readSetEnd_virt() {
+    return static_cast<Protocol_*>(this)->readSetEnd();
+  }
+
+  virtual uint32_t readBool_virt(bool& value) {
+    return static_cast<Protocol_*>(this)->readBool(value);
+  }
+
+  virtual uint32_t readBool_virt(std::vector<bool>::reference value) {
+    return static_cast<Protocol_*>(this)->readBool(value);
+  }
+
+  virtual uint32_t readByte_virt(int8_t& byte) {
+    return static_cast<Protocol_*>(this)->readByte(byte);
+  }
+
+  virtual uint32_t readI16_virt(int16_t& i16) {
+    return static_cast<Protocol_*>(this)->readI16(i16);
+  }
+
+  virtual uint32_t readI32_virt(int32_t& i32) {
+    return static_cast<Protocol_*>(this)->readI32(i32);
+  }
+
+  virtual uint32_t readI64_virt(int64_t& i64) {
+    return static_cast<Protocol_*>(this)->readI64(i64);
+  }
+
+  virtual uint32_t readDouble_virt(double& dub) {
+    return static_cast<Protocol_*>(this)->readDouble(dub);
+  }
+
+  virtual uint32_t readString_virt(std::string& str) {
+    return static_cast<Protocol_*>(this)->readString(str);
+  }
+
+  virtual uint32_t readBinary_virt(std::string& str) {
+    return static_cast<Protocol_*>(this)->readBinary(str);
+  }
+
+  virtual uint32_t skip_virt(TType type) {
+    return static_cast<Protocol_*>(this)->skip(type);
+  }
+
+  /*
+   * Provide a default skip() implementation that uses non-virtual read
+   * methods.
+   *
+   * Note: subclasses that use TVirtualProtocol to derive from another protocol
+   * implementation (i.e., not TProtocolDefaults) should beware that this may
+   * override any non-default skip() implementation provided by the parent
+   * transport class.  They may need to explicitly redefine skip() to call the
+   * correct parent implementation, if desired.
+   */
+  uint32_t skip(TType type) {
+    Protocol_* const prot = static_cast<Protocol_*>(this);
+    return ::apache::thrift::protocol::skip(*prot, type);
+  }
+
+  /*
+   * Provide a default readBool() implementation for use with
+   * std::vector<bool>, that behaves the same as reading into a normal bool.
+   *
+   * Subclasses can override this if desired, but there normally shouldn't
+   * be a need to.
+   */
+  uint32_t readBool(std::vector<bool>::reference value) {
+    bool b = false;
+    uint32_t ret = static_cast<Protocol_*>(this)->readBool(b);
+    value = b;
+    return ret;
+  }
+  using Super_::readBool; // so we don't hide readBool(bool&)
+
+ protected:
+  TVirtualProtocol(boost::shared_ptr<TTransport> ptrans)
+    : Super_(ptrans)
+  {}
+};
+
+}}} // apache::thrift::protocol
+
+#endif // #define _THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_ 1

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.cpp
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.cpp b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.cpp
new file mode 100644
index 0000000..3a3e222
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.cpp
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <thrift/qt/TQIODeviceTransport.h>
+
+#include <QAbstractSocket>
+#include <QIODevice>
+
+#include <thrift/transport/TBufferTransports.h>
+
+using boost::shared_ptr;
+  
+namespace apache { namespace thrift { namespace transport {
+
+TQIODeviceTransport::TQIODeviceTransport(shared_ptr<QIODevice> dev)
+  : dev_(dev)
+{
+}
+
+TQIODeviceTransport::~TQIODeviceTransport()
+{
+  dev_->close();
+}
+
+void TQIODeviceTransport::open()
+{
+  if (!isOpen()) {
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "open(): underlying QIODevice isn't open");
+  }
+}
+
+bool TQIODeviceTransport::isOpen()
+{
+  return dev_->isOpen();
+}
+
+bool TQIODeviceTransport::peek()
+{
+  return dev_->bytesAvailable() > 0;
+}
+
+void TQIODeviceTransport::close()
+{
+  dev_->close();
+}
+
+uint32_t TQIODeviceTransport::readAll(uint8_t* buf, uint32_t len)
+{
+  uint32_t requestLen = len;
+  while (len) {
+    uint32_t readSize;
+    try {
+      readSize = read(buf, len);
+    } catch (...) {
+      if (len != requestLen) {
+        // something read already
+        return requestLen - len;
+      }
+      // error but nothing read yet
+      throw;
+    }
+    if (readSize == 0) {
+      dev_->waitForReadyRead(50);
+    } else {
+      buf += readSize;
+      len -= readSize;
+    }
+  }
+  return requestLen;
+}
+
+uint32_t TQIODeviceTransport::read(uint8_t* buf, uint32_t len)
+{
+  uint32_t actualSize;
+  qint64 readSize;
+
+  if (!dev_->isOpen()) {
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "read(): underlying QIODevice is not open");
+  }
+
+  actualSize = (uint32_t)std::min((qint64)len, dev_->bytesAvailable());
+  readSize = dev_->read(reinterpret_cast<char *>(buf), actualSize);
+
+  if (readSize < 0) {
+    QAbstractSocket* socket;
+    if ((socket = qobject_cast<QAbstractSocket* >(dev_.get()))) {
+      throw TTransportException(TTransportException::UNKNOWN,
+                                "Failed to read() from QAbstractSocket",
+                                socket->error());
+    }
+    throw TTransportException(TTransportException::UNKNOWN,
+                              "Failed to read from from QIODevice");
+  }
+
+  return (uint32_t)readSize;
+}
+
+void TQIODeviceTransport::write(const uint8_t* buf, uint32_t len)
+{
+  while (len) {
+    uint32_t written = write_partial(buf, len);
+    len -= written;
+    dev_->waitForBytesWritten(50);
+  }
+}
+
+uint32_t TQIODeviceTransport::write_partial(const uint8_t* buf, uint32_t len)
+{
+  qint64 written;
+
+  if (!dev_->isOpen()) {
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "write_partial(): underlying QIODevice is not open");
+  }
+
+  written = dev_->write(reinterpret_cast<const char*>(buf), len);
+  if (written < 0) {
+    QAbstractSocket* socket;
+    if ((socket = qobject_cast<QAbstractSocket*>(dev_.get()))) {
+      throw TTransportException(TTransportException::UNKNOWN,
+                                "write_partial(): failed to write to QAbstractSocket", socket->error());
+    }
+
+    throw TTransportException(TTransportException::UNKNOWN,
+                              "write_partial(): failed to write to underlying QIODevice");
+  }
+
+  return (uint32_t)written;
+}
+
+void TQIODeviceTransport::flush()
+{
+  if (!dev_->isOpen()) {
+    throw TTransportException(TTransportException::NOT_OPEN,
+                              "flush(): underlying QIODevice is not open");
+  }
+
+  QAbstractSocket* socket;
+
+  if ((socket = qobject_cast<QAbstractSocket*>(dev_.get()))) {
+    socket->flush();
+  } else {
+    dev_->waitForBytesWritten(1);
+  }
+}
+
+uint8_t* TQIODeviceTransport::borrow(uint8_t* buf, uint32_t* len)
+{
+  (void) buf;
+  (void) len;
+  return NULL;
+}
+
+void TQIODeviceTransport::consume(uint32_t len)
+{
+  (void) len;
+  throw TTransportException(TTransportException::UNKNOWN);
+}
+
+}}} // apache::thrift::transport
+

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.h
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.h
new file mode 100644
index 0000000..64faa12
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQIODeviceTransport.h
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_
+#define _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ 1
+
+#include <boost/shared_ptr.hpp>
+
+#include <thrift/transport/TVirtualTransport.h>
+
+class QIODevice;
+
+namespace apache { namespace thrift { namespace transport {
+
+/**
+ *  Transport that operates on a QIODevice (socket, file, etc).
+ */
+class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> {
+ public:
+  explicit TQIODeviceTransport(boost::shared_ptr<QIODevice> dev);
+  virtual ~TQIODeviceTransport();
+
+  void open();
+  bool isOpen();
+  bool peek();
+  void close();
+
+  uint32_t readAll(uint8_t *buf, uint32_t len);
+  uint32_t read(uint8_t* buf, uint32_t len);
+
+  void write(const uint8_t* buf, uint32_t len);
+  uint32_t write_partial(const uint8_t* buf, uint32_t len);
+
+  void flush();
+
+  uint8_t* borrow(uint8_t* buf, uint32_t* len);
+  void consume(uint32_t len);
+
+ private:
+   TQIODeviceTransport(const TQIODeviceTransport&);
+   TQIODeviceTransport& operator=(const TQIODeviceTransport&);
+   
+   boost::shared_ptr<QIODevice> dev_;
+};
+}}} // apache::thrift::transport
+
+#endif // #ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_
+

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.cpp
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.cpp b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.cpp
new file mode 100644
index 0000000..79a8c59
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.cpp
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <thrift/qt/TQTcpServer.h>
+#include <thrift/qt/TQIODeviceTransport.h>
+
+#include <QTcpSocket>
+
+#include <thrift/cxxfunctional.h>
+
+#include <thrift/protocol/TProtocol.h>
+#include <thrift/async/TAsyncProcessor.h>
+
+using boost::shared_ptr;
+using apache::thrift::protocol::TProtocol;
+using apache::thrift::protocol::TProtocolFactory;
+using apache::thrift::transport::TTransport;
+using apache::thrift::transport::TTransportException;
+using apache::thrift::transport::TQIODeviceTransport;
+using apache::thrift::stdcxx::function;
+using apache::thrift::stdcxx::bind;
+
+QT_USE_NAMESPACE
+
+namespace apache { namespace thrift { namespace async {
+
+struct TQTcpServer::ConnectionContext {
+  shared_ptr<QTcpSocket> connection_;
+  shared_ptr<TTransport> transport_;
+  shared_ptr<TProtocol> iprot_;
+  shared_ptr<TProtocol> oprot_;
+
+  explicit ConnectionContext(shared_ptr<QTcpSocket> connection,
+                             shared_ptr<TTransport> transport,
+                             shared_ptr<TProtocol> iprot,
+                             shared_ptr<TProtocol> oprot)
+    : connection_(connection)
+    , transport_(transport)
+    , iprot_(iprot)
+    , oprot_(oprot)
+  {}
+};
+
+TQTcpServer::TQTcpServer(shared_ptr<QTcpServer> server,
+                         shared_ptr<TAsyncProcessor> processor,
+                         shared_ptr<TProtocolFactory> pfact,
+                         QObject* parent)
+  : QObject(parent)
+  , server_(server)
+  , processor_(processor)
+  , pfact_(pfact)
+{
+  connect(server.get(), SIGNAL(newConnection()), SLOT(processIncoming()));
+}
+
+TQTcpServer::~TQTcpServer()
+{
+}
+
+void TQTcpServer::processIncoming()
+{
+  while (server_->hasPendingConnections()) {
+    // take ownership of the QTcpSocket; technically it could be deleted
+    // when the QTcpServer is destroyed, but any real app should delete this
+    // class before deleting the QTcpServer that we are using
+    shared_ptr<QTcpSocket> connection(server_->nextPendingConnection());
+    
+    shared_ptr<TTransport> transport;
+    shared_ptr<TProtocol> iprot;
+    shared_ptr<TProtocol> oprot;
+    
+    try {
+      transport = shared_ptr<TTransport>(new TQIODeviceTransport(connection));
+      iprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport));
+      oprot = shared_ptr<TProtocol>(pfact_->getProtocol(transport));
+    } catch(...) {
+      qWarning("[TQTcpServer] Failed to initialize transports/protocols");
+      continue;
+    }
+    
+    ctxMap_[connection.get()] =
+      shared_ptr<ConnectionContext>(
+         new ConnectionContext(connection, transport, iprot, oprot));
+    
+    connect(connection.get(), SIGNAL(readyRead()), SLOT(beginDecode()));
+    
+    // need to use QueuedConnection since we will be deleting the socket in the slot
+    connect(connection.get(), SIGNAL(disconnected()), SLOT(socketClosed()),
+            Qt::QueuedConnection);
+  }
+}
+
+void TQTcpServer::beginDecode()
+{
+  QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender()));
+  Q_ASSERT(connection);
+
+  if (ctxMap_.find(connection) == ctxMap_.end()) {
+    qWarning("[TQTcpServer] Got data on an unknown QTcpSocket");
+    return;
+  }
+  
+  shared_ptr<ConnectionContext> ctx = ctxMap_[connection];
+  
+  try {
+    processor_->process(
+      bind(&TQTcpServer::finish, this,
+           ctx, apache::thrift::stdcxx::placeholders::_1),
+      ctx->iprot_, ctx->oprot_);
+  } catch(const TTransportException& ex) {
+    qWarning("[TQTcpServer] TTransportException during processing: '%s'",
+             ex.what());
+    ctxMap_.erase(connection);
+  } catch(...) {
+    qWarning("[TQTcpServer] Unknown processor exception");
+    ctxMap_.erase(connection);
+  }
+}
+
+void TQTcpServer::socketClosed()
+{
+  QTcpSocket* connection(qobject_cast<QTcpSocket*>(sender()));
+  Q_ASSERT(connection);
+
+  if (ctxMap_.find(connection) == ctxMap_.end()) {
+    qWarning("[TQTcpServer] Unknown QTcpSocket closed");
+    return;
+  }
+  
+  ctxMap_.erase(connection);
+}
+
+void TQTcpServer::finish(shared_ptr<ConnectionContext> ctx, bool healthy)
+{
+  if (!healthy) {
+    qWarning("[TQTcpServer] Processor failed to process data successfully");
+    ctxMap_.erase(ctx->connection_.get());
+  }
+}
+
+}}} // apache::thrift::async

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.h
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.h b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.h
new file mode 100644
index 0000000..12a450f
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/TQTcpServer.h
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef _THRIFT_TASYNC_QTCP_SERVER_H_
+#define _THRIFT_TASYNC_QTCP_SERVER_H_
+
+#include <QObject>
+#include <QTcpServer>
+
+#include <boost/shared_ptr.hpp>
+
+namespace apache { namespace thrift { namespace protocol {
+class TProtocolFactory;
+}}} // apache::thrift::protocol
+
+namespace apache { namespace thrift { namespace async {
+
+class TAsyncProcessor;
+
+/**
+ *  Server that uses Qt to listen for connections.
+ *  Simply give it a QTcpServer that is listening, along with an async
+ *  processor and a protocol factory, and then run the Qt event loop.
+ */
+class TQTcpServer : public QObject {
+ Q_OBJECT
+ public:
+  TQTcpServer(boost::shared_ptr<QTcpServer> server,
+              boost::shared_ptr<TAsyncProcessor> processor,
+              boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> protocolFactory,
+              QT_PREPEND_NAMESPACE(QObject)* parent = NULL);
+  virtual ~TQTcpServer();
+
+ private Q_SLOTS:
+  void processIncoming();
+  void beginDecode();
+  void socketClosed();
+
+ private:
+  TQTcpServer(const TQTcpServer&);
+  TQTcpServer& operator=(const TQTcpServer&);
+  
+  class ConnectionContext;
+
+  void finish(boost::shared_ptr<ConnectionContext> ctx, bool healthy);
+
+  boost::shared_ptr<QTcpServer> server_;
+  boost::shared_ptr<TAsyncProcessor> processor_;
+  boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> pfact_;
+
+  std::map<QT_PREPEND_NAMESPACE(QTcpSocket)*, boost::shared_ptr<ConnectionContext> > ctxMap_;
+};
+
+}}} // apache::thrift::async
+
+#endif // #ifndef _THRIFT_TASYNC_QTCP_SERVER_H_

http://git-wip-us.apache.org/repos/asf/airavata/blob/f891b7dc/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/moc_TQTcpServer.cpp
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/moc_TQTcpServer.cpp b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/moc_TQTcpServer.cpp
new file mode 100644
index 0000000..4ac3248
--- /dev/null
+++ b/airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/thrift/qt/moc_TQTcpServer.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'TQTcpServer.h'
+**
+** Created: Sun Aug 18 16:04:26 2013
+**      by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "TQTcpServer.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'TQTcpServer.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.1. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_apache__thrift__async__TQTcpServer[] = {
+
+ // content:
+       6,       // revision
+       0,       // classname
+       0,    0, // classinfo
+       3,   14, // methods
+       0,    0, // properties
+       0,    0, // enums/sets
+       0,    0, // constructors
+       0,       // flags
+       0,       // signalCount
+
+ // slots: signature, parameters, type, tag, flags
+      36,   35,   35,   35, 0x08,
+      54,   35,   35,   35, 0x08,
+      68,   35,   35,   35, 0x08,
+
+       0        // eod
+};
+
+static const char qt_meta_stringdata_apache__thrift__async__TQTcpServer[] = {
+    "apache::thrift::async::TQTcpServer\0\0"
+    "processIncoming()\0beginDecode()\0"
+    "socketClosed()\0"
+};
+
+void apache::thrift::async::TQTcpServer::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        Q_ASSERT(staticMetaObject.cast(_o));
+        TQTcpServer *_t = static_cast<TQTcpServer *>(_o);
+        switch (_id) {
+        case 0: _t->processIncoming(); break;
+        case 1: _t->beginDecode(); break;
+        case 2: _t->socketClosed(); break;
+        default: ;
+        }
+    }
+    Q_UNUSED(_a);
+}
+
+const QMetaObjectExtraData apache::thrift::async::TQTcpServer::staticMetaObjectExtraData = {
+    0,  qt_static_metacall 
+};
+
+const QMetaObject apache::thrift::async::TQTcpServer::staticMetaObject = {
+    { &QObject::staticMetaObject, qt_meta_stringdata_apache__thrift__async__TQTcpServer,
+      qt_meta_data_apache__thrift__async__TQTcpServer, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &apache::thrift::async::TQTcpServer::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *apache::thrift::async::TQTcpServer::metaObject() const
+{
+    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *apache::thrift::async::TQTcpServer::qt_metacast(const char *_clname)
+{
+    if (!_clname) return 0;
+    if (!strcmp(_clname, qt_meta_stringdata_apache__thrift__async__TQTcpServer))
+        return static_cast<void*>(const_cast< TQTcpServer*>(this));
+    return QObject::qt_metacast(_clname);
+}
+
+int apache::thrift::async::TQTcpServer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+    _id = QObject::qt_metacall(_c, _id, _a);
+    if (_id < 0)
+        return _id;
+    if (_c == QMetaObject::InvokeMetaMethod) {
+        if (_id < 3)
+            qt_static_metacall(this, _c, _id, _a);
+        _id -= 3;
+    }
+    return _id;
+}
+QT_END_MOC_NAMESPACE


Mime
View raw message