Skip to content

Commit

Permalink
Make kiwix::Server a simple wrapper around kiwix::InternalServer.
Browse files Browse the repository at this point in the history
`kiwix::Server` is now a simple exposition of a public API on top of the
private `InternalServer`.
  • Loading branch information
mgautierfr committed Oct 7, 2022
1 parent 22d94c3 commit 172e1da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 7 additions & 2 deletions include/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ namespace kiwix
* @param library The library to serve.
*/
Server(const ServerConfiguration& configuration);

virtual ~Server();

/**
Expand All @@ -123,11 +122,17 @@ namespace kiwix
*/
bool isRunning();

/**
* Get the port of the server
*/
int getPort();

/**
* Get the ipAddress of the server
*/
std::string getAddress();

protected:
ServerConfiguration m_configuration;
std::unique_ptr<InternalServer> mp_server;
};
}
Expand Down
12 changes: 2 additions & 10 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,21 @@ ServerConfiguration& ServerConfiguration::setRoot(const std::string& root)
}

Server::Server(const ServerConfiguration& configuration) :
m_configuration(configuration),
mp_server(nullptr)
mp_server(new InternalServer(configuration))
{
}

Server::~Server() = default;

bool Server::start() {
mp_server.reset(new InternalServer(m_configuration));
return mp_server->start();
}

void Server::stop() {
if (mp_server) {
mp_server->stop();
mp_server.reset(nullptr);
}
mp_server->stop();
}

bool Server::isRunning() {
if (!mp_server) {
return false;
}
return mp_server->isRunning();
}

Expand Down

0 comments on commit 172e1da

Please sign in to comment.