IRSOL
C++ code implementing socket server for interacting with Baumer camera.
factory.hpp
Go to the documentation of this file.
1
9#pragma once
10
13
14namespace irsol {
15namespace server {
16namespace handlers {
17
26template<typename HandlerT, typename... Args>
27constexpr auto
28makeHandler(std::shared_ptr<Context> ctx, Args&&... args)
29{
30 return HandlerT(ctx, std::forward<Args>(args)...);
31}
32
41template<typename InMessageT, typename LambdaT>
42constexpr auto
43makeLambdaHandler(std::shared_ptr<Context> ctx, LambdaT&& lambda)
44{
46 ctx,
47 std::function<std::vector<protocol::OutMessage>(
48 std::shared_ptr<Context>, std::shared_ptr<irsol::server::ClientSession>, InMessageT &&)>(
49 std::forward<LambdaT>(lambda))};
50}
51}
52}
53}
Handler class that delegates protocol message processing to a lambda or callable.
Declaration of the handler context struct.
Declaration of the LambdaHandler class for protocol message handling.
constexpr auto makeLambdaHandler(std::shared_ptr< Context > ctx, LambdaT &&lambda)
Constructs a lambda handler for the specified message type.
Definition factory.hpp:43
constexpr auto makeHandler(std::shared_ptr< Context > ctx, Args &&... args)
Constructs a handler instance of the given type.
Definition factory.hpp:28