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/TProcessor.h b/lib/cpp/src/TProcessor.h
index efda034..affbe81 100644
--- a/lib/cpp/src/TProcessor.h
+++ b/lib/cpp/src/TProcessor.h
@@ -13,10 +13,6 @@
namespace facebook { namespace thrift {
-using namespace boost;
-
-using namespace facebook::thrift::protocol;
-
/**
* A processor is a generic object that acts upon two streams of data, one
* an input and the other an output. The definition of this object is loose,
@@ -29,10 +25,10 @@
public:
virtual ~TProcessor() {}
- virtual bool process(shared_ptr<TProtocol> in,
- shared_ptr<TProtocol> out) = 0;
+ virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
+ boost::shared_ptr<protocol::TProtocol> out) = 0;
- bool process(shared_ptr<TProtocol> io) {
+ bool process(boost::shared_ptr<facebook::thrift::protocol::TProtocol> io) {
return process(io, io);
}
diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h
index 749ae45..d58ce6c 100644
--- a/lib/cpp/src/Thrift.h
+++ b/lib/cpp/src/Thrift.h
@@ -98,8 +98,8 @@
}
}
- uint32_t TApplicationException::read(facebook::thrift::protocol::TProtocol* iprot);
- uint32_t TApplicationException::write(facebook::thrift::protocol::TProtocol* oprot) const;
+ uint32_t TApplicationException::read(protocol::TProtocol* iprot);
+ uint32_t TApplicationException::write(protocol::TProtocol* oprot) const;
protected:
/**
diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.h b/lib/cpp/src/concurrency/PosixThreadFactory.h
index 4e50dff..ede7d79 100644
--- a/lib/cpp/src/concurrency/PosixThreadFactory.h
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.h
@@ -13,8 +13,6 @@
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
/**
* A thread factory to create posix threads
*
@@ -57,7 +55,7 @@
PosixThreadFactory(POLICY policy=ROUND_ROBIN, PRIORITY priority=NORMAL, int stackSize=1, bool detached=false);
// From ThreadFactory;
- shared_ptr<Thread> newThread(shared_ptr<Runnable> runnable) const;
+ boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
/**
* Sets stack size for created threads
@@ -85,7 +83,7 @@
private:
class Impl;
- shared_ptr<Impl> impl_;
+ boost::shared_ptr<Impl> impl_;
};
}}} // facebook::thrift::concurrency
diff --git a/lib/cpp/src/concurrency/Thread.h b/lib/cpp/src/concurrency/Thread.h
index 1b07fd5..96ca668 100644
--- a/lib/cpp/src/concurrency/Thread.h
+++ b/lib/cpp/src/concurrency/Thread.h
@@ -12,8 +12,6 @@
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
class Thread;
/**
@@ -30,18 +28,18 @@
/**
* Gets the thread object that is hosting this runnable object - can return
- * an empty shared pointer if no references remain on thet thread object
+ * an empty boost::shared pointer if no references remain on thet thread object
*/
- virtual shared_ptr<Thread> thread() { return thread_.lock(); }
+ virtual boost::shared_ptr<Thread> thread() { return thread_.lock(); }
/**
* Sets the thread that is executing this object. This is only meant for
* use by concrete implementations of Thread.
*/
- virtual void thread(shared_ptr<Thread> value) { thread_ = value; }
+ virtual void thread(boost::shared_ptr<Thread> value) { thread_ = value; }
private:
- weak_ptr<Thread> thread_;
+ boost::weak_ptr<Thread> thread_;
};
/**
@@ -74,13 +72,13 @@
/**
* Gets the runnable object this thread is hosting
*/
- virtual shared_ptr<Runnable> runnable() const { return _runnable; }
+ virtual boost::shared_ptr<Runnable> runnable() const { return _runnable; }
protected:
- virtual void runnable(shared_ptr<Runnable> value) { _runnable = value; }
+ virtual void runnable(boost::shared_ptr<Runnable> value) { _runnable = value; }
private:
- shared_ptr<Runnable> _runnable;
+ boost::shared_ptr<Runnable> _runnable;
};
/**
@@ -91,7 +89,7 @@
public:
virtual ~ThreadFactory() {}
- virtual shared_ptr<Thread> newThread(shared_ptr<Runnable> runnable) const = 0;
+ virtual boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const = 0;
};
}}} // facebook::thrift::concurrency
diff --git a/lib/cpp/src/concurrency/ThreadManager.h b/lib/cpp/src/concurrency/ThreadManager.h
index cc13665..f0c745f 100644
--- a/lib/cpp/src/concurrency/ThreadManager.h
+++ b/lib/cpp/src/concurrency/ThreadManager.h
@@ -13,8 +13,6 @@
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
/**
* Thread Pool Manager and related classes
*
@@ -81,9 +79,9 @@
virtual const STATE state() const = 0;
- virtual shared_ptr<ThreadFactory> threadFactory() const = 0;
+ virtual boost::shared_ptr<ThreadFactory> threadFactory() const = 0;
- virtual void threadFactory(shared_ptr<ThreadFactory> value) = 0;
+ virtual void threadFactory(boost::shared_ptr<ThreadFactory> value) = 0;
virtual void addWorker(size_t value=1) = 0;
@@ -114,19 +112,19 @@
*
* @param value The task to run
*/
- virtual void add(shared_ptr<Runnable>value) = 0;
+ virtual void add(boost::shared_ptr<Runnable>value) = 0;
/**
* Removes a pending task
*/
- virtual void remove(shared_ptr<Runnable> task) = 0;
+ virtual void remove(boost::shared_ptr<Runnable> task) = 0;
- static shared_ptr<ThreadManager> newThreadManager();
+ static boost::shared_ptr<ThreadManager> newThreadManager();
/**
* Creates a simple thread manager the uses count number of worker threads
*/
- static shared_ptr<ThreadManager> newSimpleThreadManager(size_t count=4);
+ static boost::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count=4);
class Task;
diff --git a/lib/cpp/src/concurrency/TimerManager.cpp b/lib/cpp/src/concurrency/TimerManager.cpp
index 09f7a9c..050885d 100644
--- a/lib/cpp/src/concurrency/TimerManager.cpp
+++ b/lib/cpp/src/concurrency/TimerManager.cpp
@@ -14,6 +14,8 @@
namespace facebook { namespace thrift { namespace concurrency {
+using boost::shared_ptr;
+
typedef std::multimap<long long, shared_ptr<TimerManager::Task> >::iterator task_iterator;
typedef std::pair<task_iterator, task_iterator> task_range;
diff --git a/lib/cpp/src/concurrency/TimerManager.h b/lib/cpp/src/concurrency/TimerManager.h
index 4e83c9e..a150e8a 100644
--- a/lib/cpp/src/concurrency/TimerManager.h
+++ b/lib/cpp/src/concurrency/TimerManager.h
@@ -17,8 +17,6 @@
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
/**
* Timer Manager
*
@@ -35,9 +33,9 @@
virtual ~TimerManager();
- virtual shared_ptr<const ThreadFactory> threadFactory() const;
+ virtual boost::shared_ptr<const ThreadFactory> threadFactory() const;
- virtual void threadFactory(shared_ptr<const ThreadFactory> value);
+ virtual void threadFactory(boost::shared_ptr<const ThreadFactory> value);
/**
* Starts the timer manager service
@@ -59,7 +57,7 @@
* @param task The task to execute
* @param timeout Time in milliseconds to delay before executing task
*/
- virtual void add(shared_ptr<Runnable> task, long long timeout);
+ virtual void add(boost::shared_ptr<Runnable> task, long long timeout);
/**
* Adds a task to be executed at some time in the future by a worker thread.
@@ -67,7 +65,7 @@
* @param task The task to execute
* @param timeout Absolute time in the future to execute task.
*/
- virtual void add(shared_ptr<Runnable> task, const struct timespec& timeout);
+ virtual void add(boost::shared_ptr<Runnable> task, const struct timespec& timeout);
/**
* Removes a pending task
@@ -79,7 +77,7 @@
* @throws UncancellableTaskException Specified task is already being
* executed or has completed execution.
*/
- virtual void remove(shared_ptr<Runnable> task);
+ virtual void remove(boost::shared_ptr<Runnable> task);
enum STATE {
UNINITIALIZED,
@@ -92,17 +90,17 @@
virtual const STATE state() const;
private:
- shared_ptr<const ThreadFactory> threadFactory_;
+ boost::shared_ptr<const ThreadFactory> threadFactory_;
class Task;
friend class Task;
- std::multimap<long long, shared_ptr<Task> > taskMap_;
+ std::multimap<long long, boost::shared_ptr<Task> > taskMap_;
size_t taskCount_;
Monitor monitor_;
STATE state_;
class Dispatcher;
friend class Dispatcher;
- shared_ptr<Dispatcher> dispatcher_;
- shared_ptr<Thread> dispatcherThread_;
+ boost::shared_ptr<Dispatcher> dispatcher_;
+ boost::shared_ptr<Thread> dispatcherThread_;
};
}}} // facebook::thrift::concurrency
diff --git a/lib/cpp/src/concurrency/test/ThreadFactoryTests.h b/lib/cpp/src/concurrency/test/ThreadFactoryTests.h
index 3f58859..90d0e4f 100644
--- a/lib/cpp/src/concurrency/test/ThreadFactoryTests.h
+++ b/lib/cpp/src/concurrency/test/ThreadFactoryTests.h
@@ -15,6 +15,7 @@
namespace facebook { namespace thrift { namespace concurrency { namespace test {
+using boost::shared_ptr;
using namespace facebook::thrift::concurrency;
/**
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.h b/lib/cpp/src/protocol/TBinaryProtocol.h
index b9bf0e9..6a85491 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/protocol/TBinaryProtocol.h
@@ -13,8 +13,6 @@
namespace facebook { namespace thrift { namespace protocol {
-using namespace boost;
-
/**
* The default binary protocol for thrift. Writes all data in a very basic
* binary format, essentially just spitting out the raw bytes.
@@ -23,14 +21,14 @@
*/
class TBinaryProtocol : public TProtocol {
public:
- TBinaryProtocol(shared_ptr<TTransport> trans) :
+ TBinaryProtocol(boost::shared_ptr<TTransport> trans) :
TProtocol(trans),
string_limit_(0),
container_limit_(0),
string_buf_(NULL),
string_buf_size_(0) {}
- TBinaryProtocol(shared_ptr<TTransport> trans,
+ TBinaryProtocol(boost::shared_ptr<TTransport> trans,
int32_t string_limit,
int32_t container_limit) :
TProtocol(trans),
diff --git a/lib/cpp/src/protocol/TProtocol.h b/lib/cpp/src/protocol/TProtocol.h
index 8b2e6bd..735268e 100644
--- a/lib/cpp/src/protocol/TProtocol.h
+++ b/lib/cpp/src/protocol/TProtocol.h
@@ -19,9 +19,7 @@
namespace facebook { namespace thrift { namespace protocol {
-using namespace boost;
-
-using namespace facebook::thrift::transport;
+using facebook::thrift::transport::TTransport;
#if __BYTE_ORDER == __BIG_ENDIAN
#define ntohll(n) (n)
@@ -290,26 +288,26 @@
}
}
- inline shared_ptr<TTransport> getTransport() {
+ inline boost::shared_ptr<TTransport> getTransport() {
return ptrans_;
}
// TODO: remove these two calls, they are for backwards
// compatibility
- inline shared_ptr<TTransport> getInputTransport() {
+ inline boost::shared_ptr<TTransport> getInputTransport() {
return ptrans_;
}
- inline shared_ptr<TTransport> getOutputTransport() {
+ inline boost::shared_ptr<TTransport> getOutputTransport() {
return ptrans_;
}
protected:
- TProtocol(shared_ptr<TTransport> ptrans):
+ TProtocol(boost::shared_ptr<TTransport> ptrans):
ptrans_(ptrans) {
trans_ = ptrans.get();
}
- shared_ptr<TTransport> ptrans_;
+ boost::shared_ptr<TTransport> ptrans_;
TTransport* trans_;
private:
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_;
};
diff --git a/lib/cpp/src/transport/TFileTransport.cpp b/lib/cpp/src/transport/TFileTransport.cpp
index 86c7df2..56009b7 100644
--- a/lib/cpp/src/transport/TFileTransport.cpp
+++ b/lib/cpp/src/transport/TFileTransport.cpp
@@ -8,17 +8,20 @@
#include "TTransportUtils.h"
#include <pthread.h>
- #include <sys/time.h>
+#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <iostream>
#include <sys/stat.h>
-using namespace std;
-
namespace facebook { namespace thrift { namespace transport {
+using boost::shared_ptr;
+using namespace std;
+using namespace facebook::thrift::protocol;
+
+
TFileTransport::TFileTransport(string path)
: readState_()
, readBuff_(NULL)
diff --git a/lib/cpp/src/transport/TFileTransport.h b/lib/cpp/src/transport/TFileTransport.h
index 635c883..235a2fe 100644
--- a/lib/cpp/src/transport/TFileTransport.h
+++ b/lib/cpp/src/transport/TFileTransport.h
@@ -18,8 +18,8 @@
namespace facebook { namespace thrift { namespace transport {
-using namespace boost;
-using std::string;
+using facebook::thrift::TProcessor;
+using facebook::thrift::protocol::TProtocolFactory;
// Data pertaining to a single event
typedef struct eventInfo {
@@ -129,7 +129,7 @@
*/
class TFileTransport : public TTransport {
public:
- TFileTransport(string path);
+ TFileTransport(std::string path);
~TFileTransport();
// TODO: what is the correct behaviour for this?
@@ -154,7 +154,7 @@
uint32_t getCurChunk();
// for changing the output file
- void resetOutputFile(int fd, string filename, long long offset);
+ void resetOutputFile(int fd, std::string filename, long long offset);
// Setter/Getter functions for user-controllable options
void setReadBuffSize(uint32_t readBuffSize) {
@@ -324,7 +324,7 @@
pthread_mutex_t mutex_;
// File information
- string filename_;
+ std::string filename_;
int fd_;
// Whether the writer thread and buffers have been initialized
@@ -339,10 +339,10 @@
};
// Exception thrown when EOF is hit
-class TEOFException : public facebook::thrift::TTransportException {
+ class TEOFException : TTransportException {
public:
TEOFException():
- facebook::thrift::TTransportException(TTransportException::END_OF_FILE) {};
+ TTransportException(TTransportException::END_OF_FILE) {};
};
@@ -356,14 +356,14 @@
* @param protocolFactory protocol factory
* @param inputTransport file transport
*/
- TFileProcessor(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> protocolFactory,
- shared_ptr<TFileTransport> inputTransport);
+ TFileProcessor(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
+ boost::shared_ptr<TFileTransport> inputTransport);
- TFileProcessor(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory,
- shared_ptr<TFileTransport> inputTransport);
+ TFileProcessor(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
+ boost::shared_ptr<TFileTransport> inputTransport);
/**
* Constructor
@@ -373,10 +373,10 @@
* @param inputTransport input file transport
* @param output output transport
*/
- TFileProcessor(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> protocolFactory,
- shared_ptr<TFileTransport> inputTransport,
- shared_ptr<TTransport> outputTransport);
+ TFileProcessor(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
+ boost::shared_ptr<TFileTransport> inputTransport,
+ boost::shared_ptr<TTransport> outputTransport);
/**
* processes events from the file
@@ -393,11 +393,11 @@
void processChunk();
private:
- shared_ptr<TProcessor> processor_;
- shared_ptr<TProtocolFactory> inputProtocolFactory_;
- shared_ptr<TProtocolFactory> outputProtocolFactory_;
- shared_ptr<TFileTransport> inputTransport_;
- shared_ptr<TTransport> outputTransport_;
+ boost::shared_ptr<TProcessor> processor_;
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory_;
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory_;
+ boost::shared_ptr<TFileTransport> inputTransport_;
+ boost::shared_ptr<TTransport> outputTransport_;
};
diff --git a/lib/cpp/src/transport/TServerSocket.h b/lib/cpp/src/transport/TServerSocket.h
index b482e02..969c00b 100644
--- a/lib/cpp/src/transport/TServerSocket.h
+++ b/lib/cpp/src/transport/TServerSocket.h
@@ -38,7 +38,7 @@
}
protected:
- shared_ptr<TTransport> acceptImpl();
+ boost::shared_ptr<TTransport> acceptImpl();
private:
int port_;
diff --git a/lib/cpp/src/transport/TServerTransport.h b/lib/cpp/src/transport/TServerTransport.h
index bb47756..9512372 100644
--- a/lib/cpp/src/transport/TServerTransport.h
+++ b/lib/cpp/src/transport/TServerTransport.h
@@ -13,8 +13,6 @@
namespace facebook { namespace thrift { namespace transport {
-using namespace boost;
-
/**
* Server transport framework. A server needs to have some facility for
* creating base transports to read/write from.
@@ -43,8 +41,8 @@
* @return A new TTransport object
* @throws TTransportException if there is an error
*/
- shared_ptr<TTransport> accept() {
- shared_ptr<TTransport> result = acceptImpl();
+ boost::shared_ptr<TTransport> accept() {
+ boost::shared_ptr<TTransport> result = acceptImpl();
if (result == NULL) {
throw TTransportException("accept() may not return NULL");
}
@@ -73,7 +71,7 @@
* @return A newly allocated TTransport object
* @throw TTransportException If an error occurs
*/
- virtual shared_ptr<TTransport> acceptImpl() = 0;
+ virtual boost::shared_ptr<TTransport> acceptImpl() = 0;
};