Get rid of all the using namespace and using boost:: declarations in Thrift header files
Summary: To remove upstream dependencies. Still keeping some specific using directives around.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665047 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TNonblockingServer.cpp b/lib/cpp/src/server/TNonblockingServer.cpp
index e73da12..2b910a5 100644
--- a/lib/cpp/src/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/server/TNonblockingServer.cpp
@@ -15,7 +15,10 @@
namespace facebook { namespace thrift { namespace server {
- void TConnection::init(int socket, short eventFlags, TNonblockingServer* s) {
+using namespace facebook::thrift::protocol;
+using namespace facebook::thrift::transport;
+
+void TConnection::init(int socket, short eventFlags, TNonblockingServer* s) {
socket_ = socket;
server_ = s;
appState_ = APP_INIT;
diff --git a/lib/cpp/src/server/TNonblockingServer.h b/lib/cpp/src/server/TNonblockingServer.h
index abfd5fa..e4f8346 100644
--- a/lib/cpp/src/server/TNonblockingServer.h
+++ b/lib/cpp/src/server/TNonblockingServer.h
@@ -15,7 +15,8 @@
namespace facebook { namespace thrift { namespace server {
-using boost::shared_ptr;
+using facebook::thrift::transport::TMemoryBuffer;
+using facebook::thrift::protocol::TProtocol;
// Forward declaration of class
class TConnection;
@@ -56,31 +57,31 @@
void handleEvent(int fd, short which);
public:
- TNonblockingServer(shared_ptr<TProcessor> processor,
+ TNonblockingServer(boost::shared_ptr<TProcessor> processor,
int port) :
TServer(processor),
serverSocket_(0),
port_(port),
frameResponses_(true) {}
- TNonblockingServer(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> protocolFactory,
+ TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
int port) :
TServer(processor),
serverSocket_(0),
port_(port),
frameResponses_(true) {
- setInputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setOutputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
setInputProtocolFactory(protocolFactory);
setOutputProtocolFactory(protocolFactory);
}
- TNonblockingServer(shared_ptr<TProcessor> processor,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory,
+ TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
int port) :
TServer(processor),
serverSocket_(0),
@@ -186,20 +187,20 @@
int32_t frameSize_;
// Transport to read from
- shared_ptr<TMemoryBuffer> inputTransport_;
+ boost::shared_ptr<TMemoryBuffer> inputTransport_;
// Transport that processor writes to
- shared_ptr<TMemoryBuffer> outputTransport_;
+ boost::shared_ptr<TMemoryBuffer> outputTransport_;
// extra transport generated by transport factory (e.g. BufferedRouterTransport)
- shared_ptr<TTransport> factoryInputTransport_;
- shared_ptr<TTransport> factoryOutputTransport_;
+ boost::shared_ptr<TTransport> factoryInputTransport_;
+ boost::shared_ptr<TTransport> factoryOutputTransport_;
// Protocol decoder
- shared_ptr<TProtocol> inputProtocol_;
+ boost::shared_ptr<TProtocol> inputProtocol_;
// Protocol encoder
- shared_ptr<TProtocol> outputProtocol_;
+ boost::shared_ptr<TProtocol> outputProtocol_;
// Go into read mode
void setRead() {
@@ -233,8 +234,8 @@
// Allocate input and output tranpsorts
// these only need to be allocated once per TConnection (they don't need to be
// reallocated on init() call)
- inputTransport_ = shared_ptr<TMemoryBuffer>(new TMemoryBuffer(readBuffer_, readBufferSize_));
- outputTransport_ = shared_ptr<TMemoryBuffer>(new TMemoryBuffer());
+ inputTransport_ = boost::shared_ptr<TMemoryBuffer>(new TMemoryBuffer(readBuffer_, readBufferSize_));
+ outputTransport_ = boost::shared_ptr<TMemoryBuffer>(new TMemoryBuffer());
init(socket, eventFlags, s);
}
diff --git a/lib/cpp/src/server/TServer.h b/lib/cpp/src/server/TServer.h
index 2936e42..5f13255 100644
--- a/lib/cpp/src/server/TServer.h
+++ b/lib/cpp/src/server/TServer.h
@@ -16,9 +16,12 @@
namespace facebook { namespace thrift { namespace server {
-using namespace facebook::thrift;
-using namespace facebook::thrift::transport;
-using namespace boost;
+using facebook::thrift::TProcessor;
+using facebook::thrift::protocol::TBinaryProtocolFactory;
+using facebook::thrift::protocol::TProtocolFactory;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransport;
+using facebook::thrift::transport::TTransportFactory;
/**
* Thrift server.
@@ -38,53 +41,53 @@
serve();
}
- shared_ptr<TProcessor> getProcessor() {
+ boost::shared_ptr<TProcessor> getProcessor() {
return processor_;
}
- shared_ptr<TServerTransport> getServerTransport() {
+ boost::shared_ptr<TServerTransport> getServerTransport() {
return serverTransport_;
}
- shared_ptr<TTransportFactory> getInputTransportFactory() {
+ boost::shared_ptr<TTransportFactory> getInputTransportFactory() {
return inputTransportFactory_;
}
- shared_ptr<TTransportFactory> getOutputTransportFactory() {
+ boost::shared_ptr<TTransportFactory> getOutputTransportFactory() {
return outputTransportFactory_;
}
- shared_ptr<TProtocolFactory> getInputProtocolFactory() {
+ boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() {
return inputProtocolFactory_;
}
- shared_ptr<TProtocolFactory> getOutputProtocolFactory() {
+ boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() {
return outputProtocolFactory_;
}
protected:
- TServer(shared_ptr<TProcessor> processor):
+ TServer(boost::shared_ptr<TProcessor> processor):
processor_(processor) {
- setInputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setOutputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setInputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
- setOutputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
}
- TServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport):
+ TServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport):
processor_(processor),
serverTransport_(serverTransport) {
- setInputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setOutputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setInputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
- setOutputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
}
- TServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory):
+ TServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory):
processor_(processor),
serverTransport_(serverTransport),
inputTransportFactory_(transportFactory),
@@ -92,12 +95,12 @@
inputProtocolFactory_(protocolFactory),
outputProtocolFactory_(protocolFactory) {}
- TServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory):
+ TServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
processor_(processor),
serverTransport_(serverTransport),
inputTransportFactory_(inputTransportFactory),
@@ -107,28 +110,28 @@
// Class variables
- shared_ptr<TProcessor> processor_;
- shared_ptr<TServerTransport> serverTransport_;
+ boost::shared_ptr<TProcessor> processor_;
+ boost::shared_ptr<TServerTransport> serverTransport_;
- shared_ptr<TTransportFactory> inputTransportFactory_;
- shared_ptr<TTransportFactory> outputTransportFactory_;
+ boost::shared_ptr<TTransportFactory> inputTransportFactory_;
+ boost::shared_ptr<TTransportFactory> outputTransportFactory_;
- shared_ptr<TProtocolFactory> inputProtocolFactory_;
- shared_ptr<TProtocolFactory> outputProtocolFactory_;
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory_;
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory_;
- void setInputTransportFactory(shared_ptr<TTransportFactory> inputTransportFactory) {
+ void setInputTransportFactory(boost::shared_ptr<TTransportFactory> inputTransportFactory) {
inputTransportFactory_ = inputTransportFactory;
}
- void setOutputTransportFactory(shared_ptr<TTransportFactory> outputTransportFactory) {
+ void setOutputTransportFactory(boost::shared_ptr<TTransportFactory> outputTransportFactory) {
outputTransportFactory_ = outputTransportFactory;
}
- void setInputProtocolFactory(shared_ptr<TProtocolFactory> inputProtocolFactory) {
+ void setInputProtocolFactory(boost::shared_ptr<TProtocolFactory> inputProtocolFactory) {
inputProtocolFactory_ = inputProtocolFactory;
}
- void setOutputProtocolFactory(shared_ptr<TProtocolFactory> outputProtocolFactory) {
+ void setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory> outputProtocolFactory) {
outputProtocolFactory_ = outputProtocolFactory;
}
diff --git a/lib/cpp/src/server/TSimpleServer.cpp b/lib/cpp/src/server/TSimpleServer.cpp
index 40d7ed9..d5d3797 100644
--- a/lib/cpp/src/server/TSimpleServer.cpp
+++ b/lib/cpp/src/server/TSimpleServer.cpp
@@ -8,10 +8,15 @@
#include "transport/TTransportException.h"
#include <string>
#include <iostream>
-using namespace std;
namespace facebook { namespace thrift { namespace server {
+using namespace std;
+using namespace facebook::thrift;
+using namespace facebook::thrift::protocol;
+using namespace facebook::thrift::transport;
+using boost::shared_ptr;
+
/**
* A simple single-threaded application server. Perfect for unit tests!
*
diff --git a/lib/cpp/src/server/TSimpleServer.h b/lib/cpp/src/server/TSimpleServer.h
index 0bb0365..b02f106 100644
--- a/lib/cpp/src/server/TSimpleServer.h
+++ b/lib/cpp/src/server/TSimpleServer.h
@@ -22,19 +22,19 @@
*/
class TSimpleServer : public TServer {
public:
- TSimpleServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory) :
+ TSimpleServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory) :
TServer(processor, serverTransport, transportFactory, protocolFactory),
stop_(false) {}
- TSimpleServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory):
+ TSimpleServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
TServer(processor, serverTransport,
inputTransportFactory, outputTransportFactory,
inputProtocolFactory, outputProtocolFactory),
diff --git a/lib/cpp/src/server/TThreadPoolServer.cpp b/lib/cpp/src/server/TThreadPoolServer.cpp
index 2542de9..c8a8693 100644
--- a/lib/cpp/src/server/TThreadPoolServer.cpp
+++ b/lib/cpp/src/server/TThreadPoolServer.cpp
@@ -13,9 +13,11 @@
namespace facebook { namespace thrift { namespace server {
+using boost::shared_ptr;
using namespace std;
using namespace facebook::thrift;
using namespace facebook::thrift::concurrency;
+using namespace facebook::thrift::protocol;;
using namespace facebook::thrift::transport;
class TThreadPoolServer::Task: public Runnable {
diff --git a/lib/cpp/src/server/TThreadPoolServer.h b/lib/cpp/src/server/TThreadPoolServer.h
index bdb0e47..fd74501 100644
--- a/lib/cpp/src/server/TThreadPoolServer.h
+++ b/lib/cpp/src/server/TThreadPoolServer.h
@@ -15,27 +15,28 @@
namespace facebook { namespace thrift { namespace server {
-using namespace facebook::thrift::concurrency;
-using namespace facebook::thrift::transport;
-using namespace boost;
+using facebook::thrift::concurrency::ThreadManager;
+using facebook::thrift::protocol::TProtocolFactory;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransportFactory;
class TThreadPoolServer : public TServer {
public:
class Task;
- TThreadPoolServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory,
- shared_ptr<ThreadManager> threadManager);
+ TThreadPoolServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
+ boost::shared_ptr<ThreadManager> threadManager);
- TThreadPoolServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory,
- shared_ptr<ThreadManager> threadManager);
+ TThreadPoolServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
+ boost::shared_ptr<ThreadManager> threadManager);
virtual ~TThreadPoolServer();
@@ -48,7 +49,7 @@
protected:
- shared_ptr<ThreadManager> threadManager_;
+ boost::shared_ptr<ThreadManager> threadManager_;
volatile bool stop_;
diff --git a/lib/cpp/src/server/TThreadedServer.cpp b/lib/cpp/src/server/TThreadedServer.cpp
index 85c72dc..079e046 100644
--- a/lib/cpp/src/server/TThreadedServer.cpp
+++ b/lib/cpp/src/server/TThreadedServer.cpp
@@ -15,8 +15,10 @@
namespace facebook { namespace thrift { namespace server {
+using boost::shared_ptr;
using namespace std;
using namespace facebook::thrift;
+using namespace facebook::thrift::protocol;
using namespace facebook::thrift::transport;
using namespace facebook::thrift::concurrency;
diff --git a/lib/cpp/src/server/TThreadedServer.h b/lib/cpp/src/server/TThreadedServer.h
index 453eda5..c6306b2 100644
--- a/lib/cpp/src/server/TThreadedServer.h
+++ b/lib/cpp/src/server/TThreadedServer.h
@@ -15,26 +15,27 @@
namespace facebook { namespace thrift { namespace server {
-using namespace facebook::thrift::transport;
-using namespace facebook::thrift::concurrency;
-using namespace boost;
+using facebook::thrift::TProcessor;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransportFactory;
+using facebook::thrift::concurrency::ThreadFactory;
class TThreadedServer : public TServer {
public:
class Task;
- TThreadedServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory);
+ TThreadedServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory);
virtual ~TThreadedServer();
virtual void serve();
protected:
- shared_ptr<ThreadFactory> threadFactory_;
+ boost::shared_ptr<ThreadFactory> threadFactory_;
};