Commit 9c2e8ecd authored by legoc's avatar legoc
Browse files

Simplified use of m_impl in Services, Server, This

parent 3e85db72
...@@ -112,7 +112,6 @@ void This::terminate() { ...@@ -112,7 +112,6 @@ void This::terminate() {
This::This() : This::This() :
Services(), Services(),
m_impl(nullptr),
m_id(-1), m_id(-1),
m_managed(false), m_managed(false),
m_starterId(0) { m_starterId(0) {
...@@ -120,8 +119,7 @@ This::This() : ...@@ -120,8 +119,7 @@ This::This() :
void This::initApplication(int argc, char *argv[]) { void This::initApplication(int argc, char *argv[]) {
m_impl = new ServicesImpl(); Services::init();
Services::setImpl(m_impl);
if (argc == 0) { if (argc == 0) {
throw InvalidArgumentException("missing info argument"); throw InvalidArgumentException("missing info argument");
......
...@@ -164,7 +164,6 @@ private: ...@@ -164,7 +164,6 @@ private:
void stoppingFunction(StopFunctionType stop); void stoppingFunction(StopFunctionType stop);
void handleStopImpl(StopFunctionType function); void handleStopImpl(StopFunctionType function);
ServicesImpl * m_impl;
std::string m_name; std::string m_name;
int m_id; int m_id;
bool m_managed; bool m_managed;
......
...@@ -32,7 +32,7 @@ namespace cameo { ...@@ -32,7 +32,7 @@ namespace cameo {
Server::Server(const std::string& endpoint) : Server::Server(const std::string& endpoint) :
Services() { Services() {
Services::setImpl(new ServicesImpl()); Services::init();
vector<string> tokens = split(endpoint); vector<string> tokens = split(endpoint);
......
...@@ -44,8 +44,9 @@ void Services::terminate() { ...@@ -44,8 +44,9 @@ void Services::terminate() {
m_impl.reset(); m_impl.reset();
} }
void Services::setImpl(ServicesImpl * impl) { void Services::init() {
m_impl.reset(impl); // Set the impl.
m_impl.reset(new ServicesImpl());
} }
std::vector<std::string> Services::split(const std::string& info) { std::vector<std::string> Services::split(const std::string& info) {
......
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
void terminate(); void terminate();
void setImpl(ServicesImpl * impl); void init();
std::vector<std::string> split(const std::string& info); std::vector<std::string> split(const std::string& info);
void setTimeout(int timeout); void setTimeout(int timeout);
...@@ -57,6 +57,7 @@ public: ...@@ -57,6 +57,7 @@ public:
int m_statusPort; int m_statusPort;
std::string m_serverStatusEndpoint; std::string m_serverStatusEndpoint;
std::unique_ptr<ServicesImpl> m_impl; std::unique_ptr<ServicesImpl> m_impl;
std::unique_ptr<RequestSocketImpl> m_requestSocket;
}; };
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment