mirror of https://github.com/kiwix/libkiwix.git
Make `kiwix::Server` a simple wrapper around `kiwix::InternalServer`.
`kiwix::Server` is now a simple exposition of a public API on top of the private `InternalServer`.
This commit is contained in:
parent
1fcc2ad709
commit
d1124704f9
|
@ -104,7 +104,6 @@ namespace kiwix
|
||||||
* @param library The library to serve.
|
* @param library The library to serve.
|
||||||
*/
|
*/
|
||||||
explicit Server(const Configuration& configuration);
|
explicit Server(const Configuration& configuration);
|
||||||
|
|
||||||
virtual ~Server();
|
virtual ~Server();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,11 +121,17 @@ namespace kiwix
|
||||||
*/
|
*/
|
||||||
bool isRunning();
|
bool isRunning();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the port of the server
|
||||||
|
*/
|
||||||
int getPort();
|
int getPort();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ipAddress of the server
|
||||||
|
*/
|
||||||
std::string getAddress();
|
std::string getAddress();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Configuration m_configuration;
|
|
||||||
std::unique_ptr<InternalServer> mp_server;
|
std::unique_ptr<InternalServer> mp_server;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,29 +42,21 @@ Server::Configuration& Server::Configuration::setRoot(const std::string& root)
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::Server(const Server::Configuration& configuration) :
|
Server::Server(const Server::Configuration& configuration) :
|
||||||
m_configuration(configuration),
|
mp_server(new InternalServer(configuration))
|
||||||
mp_server(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::~Server() = default;
|
Server::~Server() = default;
|
||||||
|
|
||||||
bool Server::start() {
|
bool Server::start() {
|
||||||
mp_server.reset(new InternalServer(m_configuration));
|
|
||||||
return mp_server->start();
|
return mp_server->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::stop() {
|
void Server::stop() {
|
||||||
if (mp_server) {
|
|
||||||
mp_server->stop();
|
mp_server->stop();
|
||||||
mp_server.reset(nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::isRunning() {
|
bool Server::isRunning() {
|
||||||
if (!mp_server) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return mp_server->isRunning();
|
return mp_server->isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue