updated tour

This commit is contained in:
Günter Obiltschnig 2020-01-27 10:46:55 +01:00
parent f828ae1e1f
commit e522f90513
2 changed files with 65 additions and 83 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -69,7 +69,7 @@ and a pointer to a member function. The event can be fired by calling
#include <iostream>
using Poco::BasicEvent;
using Poco::Delegate;
using Poco::delegate;
class Source
{
@ -96,13 +96,11 @@ and a pointer to a member function. The event can be fired by calling
Source source;
Target target;
source.theEvent += Delegate<Target, int>(
&target, &Target::onEvent);
source.theEvent += delegate(&target, &Target::onEvent);
source.fireEvent(42);
source.theEvent -= Delegate<Target, int>(
&target, &Target::onEvent);
source.theEvent -= delegate(&target, &Target::onEvent);
return 0;
}
@ -315,12 +313,11 @@ server.
{
}
void handleRequest(HTTPServerRequest& request,
HTTPServerResponse& response)
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{
Application& app = Application::instance();
app.logger().information("Request from "
+ request.clientAddress().toString());
app.logger().information("Request from %s",
request.clientAddress().toString());
Timestamp now;
std::string dt(DateTimeFormatter::format(now, _format));
@ -350,8 +347,7 @@ server.
{
}
HTTPRequestHandler* createRequestHandler(
const HTTPServerRequest& request)
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
{
if (request.getURI() == "/")
return new TimeRequestHandler(_format);
@ -365,15 +361,6 @@ server.
class HTTPTimeServer: public Poco::Util::ServerApplication
{
public:
HTTPTimeServer(): _helpRequested(false)
{
}
~HTTPTimeServer()
{
}
protected:
void initialize(Application& self)
{
@ -381,11 +368,6 @@ server.
ServerApplication::initialize(self);
}
void uninitialize()
{
ServerApplication::uninitialize();
}
void defineOptions(OptionSet& options)
{
ServerApplication::defineOptions(options);
@ -398,8 +380,7 @@ server.
this, &HTTPTimeServer::handleHelp)));
}
void handleHelp(const std::string& name,
const std::string& value)
void handleHelp(const std::string& name, const std::string& value)
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
@ -415,14 +396,15 @@ server.
{
if (!_helpRequested)
{
unsigned short port = (unsigned short)
config().getInt("HTTPTimeServer.port", 9980);
std::string format(
config().getString("HTTPTimeServer.format",
unsigned short port = static_cast<unsigned short>(
config().getInt("HTTPTimeServer.port", 9980));
std::string format(config().getString(
"HTTPTimeServer.format",
DateTimeFormat::SORTABLE_FORMAT));
ServerSocket svs(port);
HTTPServer srv(new TimeRequestHandlerFactory(format),
HTTPServer srv(
new TimeRequestHandlerFactory(format),
svs, new HTTPServerParams);
srv.start();
waitForTerminationRequest();
@ -432,7 +414,7 @@ server.
}
private:
bool _helpRequested;
bool _helpRequested = false;
};
int main(int argc, char** argv)