2015-01-27 06:35:29 -05:00
|
|
|
#ifndef REQUEST_HANDLER_HPP
|
|
|
|
#define REQUEST_HANDLER_HPP
|
2011-01-09 16:42:27 -05:00
|
|
|
|
2016-01-28 10:28:44 -05:00
|
|
|
#include "server/service_handler.hpp"
|
|
|
|
|
2013-06-26 19:48:02 -04:00
|
|
|
#include <string>
|
2011-01-09 16:42:27 -05:00
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::server
|
2016-01-05 10:51:13 -05:00
|
|
|
{
|
2013-12-16 05:29:38 -05:00
|
|
|
|
2014-05-11 12:03:05 -04:00
|
|
|
namespace http
|
|
|
|
{
|
2015-01-27 05:45:33 -05:00
|
|
|
class reply;
|
|
|
|
struct request;
|
2020-11-26 10:21:39 -05:00
|
|
|
} // namespace http
|
2014-03-03 12:47:34 -05:00
|
|
|
|
2014-05-07 10:50:48 -04:00
|
|
|
class RequestHandler
|
|
|
|
{
|
2013-12-13 17:26:57 -05:00
|
|
|
|
2014-05-11 12:03:05 -04:00
|
|
|
public:
|
2016-02-12 22:23:59 -05:00
|
|
|
RequestHandler() = default;
|
2014-05-07 10:50:48 -04:00
|
|
|
RequestHandler(const RequestHandler &) = delete;
|
Takes care of proper special member generation globally, fixes #1689
Phew, a lot of classes were affected by this. The rationale for the
changes are as follows:
- When a type X declares any constructor, the default constructor is
not declared, so there is no need for X() = delete there. In fact,
there is brutal difference between those two: deleted members
participate in overload resolution, but not-declared members do not!
- When a type X wants to be non-copyable (e.g. to be only movable, like
threads, unique_ptrs, and so on), you can either do it by inheriting
from boost::noncopyable (the old way), or better declare both (!) the
copy constructor _and_ the copy assignment operator as deleted:
X(X const&) = delete;
X& operator=(X const&) = delete;
We had tons of types with deleted copy constructors that were lacking
a corresponding deleted copy assignment operator, making them still
copyable and you wouldn't even notice (read: scary)!
References:
- http://accu.org/content/conf2014/Howard_Hinnant_Accu_2014.pdf
- http://www.boost.org/doc/libs/master/libs/core/doc/html/core/noncopyable.html
Note: I know, I'm quoting Hinnant's extraordinary slides a lot, but
getting the sematic right here is so incredibly important.
2016-01-27 05:20:55 -05:00
|
|
|
RequestHandler &operator=(const RequestHandler &) = delete;
|
2013-12-13 17:26:57 -05:00
|
|
|
|
2016-10-27 06:26:23 -04:00
|
|
|
void RegisterServiceHandler(std::unique_ptr<ServiceHandlerInterface> service_handler);
|
2016-01-28 10:28:44 -05:00
|
|
|
|
|
|
|
void HandleRequest(const http::request ¤t_request, http::reply ¤t_reply);
|
2013-12-13 17:26:57 -05:00
|
|
|
|
2014-05-11 12:03:05 -04:00
|
|
|
private:
|
2016-10-27 06:26:23 -04:00
|
|
|
std::unique_ptr<ServiceHandlerInterface> service_handler;
|
2011-01-09 16:42:27 -05:00
|
|
|
};
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::server
|
2016-01-05 10:51:13 -05:00
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
#endif // REQUEST_HANDLER_HPP
|