THRIFT-1316. cpp: update server classes to accept
TProcessorFactory objects

Patch: Adam Simpkins

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1164201 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TThreadedServer.h b/lib/cpp/src/server/TThreadedServer.h
index 4d0811a..2db3fac 100644
--- a/lib/cpp/src/server/TThreadedServer.h
+++ b/lib/cpp/src/server/TThreadedServer.h
@@ -40,16 +40,35 @@
  public:
   class Task;
 
-  TThreadedServer(boost::shared_ptr<TProcessor> processor,
-                  boost::shared_ptr<TServerTransport> serverTransport,
-                  boost::shared_ptr<TTransportFactory> transportFactory,
-                  boost::shared_ptr<TProtocolFactory> protocolFactory);
+  template<typename ProcessorFactory>
+  TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                  const boost::shared_ptr<TServerTransport>& serverTransport,
+                  const boost::shared_ptr<TTransportFactory>& transportFactory,
+                  const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                  THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory));
 
-  TThreadedServer(boost::shared_ptr<TProcessor> processor,
-                  boost::shared_ptr<TServerTransport> serverTransport,
-                  boost::shared_ptr<TTransportFactory> transportFactory,
-                  boost::shared_ptr<TProtocolFactory> protocolFactory,
-                  boost::shared_ptr<ThreadFactory> threadFactory);
+  template<typename ProcessorFactory>
+  TThreadedServer(const boost::shared_ptr<ProcessorFactory>& processorFactory,
+                  const boost::shared_ptr<TServerTransport>& serverTransport,
+                  const boost::shared_ptr<TTransportFactory>& transportFactory,
+                  const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                  const boost::shared_ptr<ThreadFactory>& threadFactory,
+                  THRIFT_OVERLOAD_IF(ProcessorFactory, TProtocolFactory));
+
+  template<typename Processor>
+  TThreadedServer(const boost::shared_ptr<Processor>& processor,
+                  const boost::shared_ptr<TServerTransport>& serverTransport,
+                  const boost::shared_ptr<TTransportFactory>& transportFactory,
+                  const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                  THRIFT_OVERLOAD_IF(Processor, TProcessor));
+
+  template<typename Processor>
+  TThreadedServer(const boost::shared_ptr<Processor>& processor,
+                  const boost::shared_ptr<TServerTransport>& serverTransport,
+                  const boost::shared_ptr<TTransportFactory>& transportFactory,
+                  const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+                  const boost::shared_ptr<ThreadFactory>& threadFactory,
+                  THRIFT_OVERLOAD_IF(Processor, TProcessor));
 
   virtual ~TThreadedServer();
 
@@ -61,6 +80,8 @@
   }
 
  protected:
+  void init();
+
   boost::shared_ptr<ThreadFactory> threadFactory_;
   volatile bool stop_;
 
@@ -69,6 +90,56 @@
 
 };
 
+template<typename ProcessorFactory>
+TThreadedServer::TThreadedServer(
+    const boost::shared_ptr<ProcessorFactory>& processorFactory,
+    const boost::shared_ptr<TServerTransport>& serverTransport,
+    const boost::shared_ptr<TTransportFactory>& transportFactory,
+    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+    THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProcessorFactory)) :
+  TServer(processorFactory, serverTransport, transportFactory,
+          protocolFactory) {
+  init();
+}
+
+template<typename ProcessorFactory>
+TThreadedServer::TThreadedServer(
+    const boost::shared_ptr<ProcessorFactory>& processorFactory,
+    const boost::shared_ptr<TServerTransport>& serverTransport,
+    const boost::shared_ptr<TTransportFactory>& transportFactory,
+    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+    const boost::shared_ptr<ThreadFactory>& threadFactory,
+    THRIFT_OVERLOAD_IF_DEFN(ProcessorFactory, TProtocolFactory)) :
+  TServer(processorFactory, serverTransport, transportFactory,
+          protocolFactory),
+  threadFactory_(threadFactory) {
+  init();
+}
+
+template<typename Processor>
+TThreadedServer::TThreadedServer(
+    const boost::shared_ptr<Processor>& processor,
+    const boost::shared_ptr<TServerTransport>& serverTransport,
+    const boost::shared_ptr<TTransportFactory>& transportFactory,
+    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+    THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor)) :
+  TServer(processor, serverTransport, transportFactory, protocolFactory) {
+  init();
+}
+
+template<typename Processor>
+TThreadedServer::TThreadedServer(
+    const boost::shared_ptr<Processor>& processor,
+    const boost::shared_ptr<TServerTransport>& serverTransport,
+    const boost::shared_ptr<TTransportFactory>& transportFactory,
+    const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+    const boost::shared_ptr<ThreadFactory>& threadFactory,
+    THRIFT_OVERLOAD_IF_DEFN(Processor, TProcessor)) :
+  TServer(processor, serverTransport, transportFactory, protocolFactory),
+  threadFactory_(threadFactory) {
+  init();
+}
+
 }}} // apache::thrift::server
 
 #endif // #ifndef _THRIFT_SERVER_TTHREADEDSERVER_H_