-- added stubs for readEnd() and writeEnd()
authorAditya Agarwal <aditya@apache.org>
Tue, 5 Sep 2006 22:49:53 +0000 (22:49 +0000)
committerAditya Agarwal <aditya@apache.org>
Tue, 5 Sep 2006 22:49:53 +0000 (22:49 +0000)
Summary:
-- these are hook points that thrift_logger/logfile will integrate with..

Reviewed By: McSlee

Test Plan: Generated thrift code

Notes:
-- Thrift logfiles are soon coming to a netapp near you!

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664787 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_cpp_generator.cc
lib/cpp/src/transport/TTransport.h

index 7934f0c..b43ee16 100644 (file)
@@ -982,6 +982,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
     indent() << argsname << " __args;" << endl <<
     indent() << "__args.read(_iprot, itrans);" << endl <<
     indent() << "_iprot->readMessageEnd(itrans);" << endl <<
+    indent() << "itrans->readEnd();" << endl <<
     endl;
 
   t_struct* xs = tfunction->get_xceptions();
@@ -1064,7 +1065,8 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
     indent() << "_oprot->writeMessageBegin(otrans, \"" << tfunction->get_name() << "\", facebook::thrift::protocol::T_REPLY, seqid);" << endl <<
     indent() << "__result.write(_oprot, otrans);" << endl <<
     indent() << "_oprot->writeMessageEnd(otrans);" << endl <<
-    indent() << "otrans->flush();" << endl;
+    indent() << "otrans->flush();" << endl <<
+    indent() << "otrans->writeEnd();" << endl;
     
   // Close function
   scope_down(f_service_);
index b2e2a5b..19a2cb6 100644 (file)
@@ -71,6 +71,17 @@ class TTransport {
     return have;
   }
 
+  /**
+   * Called when read is completed. 
+   * This can be over-ridden to perform a transport-specific action
+   * e.g. logging the request to a file
+   *
+   */
+  virtual void readEnd() {
+    // default behaviour is to do nothing
+    return;
+  }
+
   /**
    * Writes the string in its entirety to the buffer.
    *
@@ -81,6 +92,17 @@ class TTransport {
     throw TTransportException(TTX_NOT_OPEN, "Base TTransport cannot write.");
   }
 
+  /**
+   * Called when write is completed. 
+   * This can be over-ridden to perform a transport-specific action
+   * at the end of a request.
+   *
+   */
+  virtual void writeEnd() {
+    // default behaviour is to do nothing
+    return;
+  }
+
   /**
    * Flushes any pending data to be written. Typically used with buffered
    * transport mechanisms.