20 #ifndef MIR_FRONTEND_TEMPLATE_PROTOBUF_MESSAGE_PROCESSOR_H_
21 #define MIR_FRONTEND_TEMPLATE_PROTOBUF_MESSAGE_PROCESSOR_H_
25 #include <google/protobuf/stubs/common.h>
26 #include <boost/exception/diagnostic_information.hpp>
42 { typedef ::google::protobuf::MessageLite*
type; };
46 template<
class Self,
class Server,
class ServerX,
class ParameterMessage,
class ResultMessage>
50 void (ServerX::*
function)(
51 ParameterMessage
const* request,
52 ResultMessage* response,
53 ::google::protobuf::Closure* done),
56 ParameterMessage parameter_message;
57 if (!parameter_message.ParseFromString(invocation.
parameters()))
58 BOOST_THROW_EXCEPTION(std::runtime_error(
"Failed to parse message parameters!"));
59 ResultMessage result_message;
63 std::unique_ptr<google::protobuf::Closure> callback(
64 google::protobuf::NewPermanentCallback<
66 ::google::protobuf::uint32,
78 catch (std::exception
const& x)
80 using namespace std::literals::string_literals;
81 result_message.set_error(
"Error processing request: "s +
82 x.what() +
"\nInternal error details: " + boost::diagnostic_information(x));
83 self->send_response(invocation.
id(), &result_message);
All things Mir.
Definition: atomic_callback.h:25
Definition: message_processor.h:40
Customise and run a Mir server.
Definition: server.h:75
google::protobuf::uint32 id() const
void invoke(Self *self, Server *server, void(ServerX::*function)(ParameterMessage const *request, ResultMessage *response,::google::protobuf::Closure *done), Invocation const &invocation)
Definition: template_protobuf_message_processor.h:47
const ::std::string & parameters() const
Definition: template_protobuf_message_processor.h:41
::google::protobuf::MessageLite * type
Definition: template_protobuf_message_processor.h:42