20 #ifndef MIR_FRONTEND_TEMPLATE_PROTOBUF_MESSAGE_PROCESSOR_H_ 21 #define MIR_FRONTEND_TEMPLATE_PROTOBUF_MESSAGE_PROCESSOR_H_ 26 #include <google/protobuf/stubs/common.h> 27 #include <boost/exception/diagnostic_information.hpp> 43 { typedef ::google::protobuf::MessageLite*
type; };
47 template<
class Self,
class Server,
class ServerX,
class ParameterMessage,
class ResultMessage>
51 void (ServerX::*
function)(
52 ParameterMessage
const* request,
53 ResultMessage* response,
54 ::google::protobuf::Closure* done),
57 ParameterMessage parameter_message;
58 if (!parameter_message.ParseFromString(invocation.
parameters()))
59 BOOST_THROW_EXCEPTION(std::runtime_error(
"Failed to parse message parameters!"));
60 ResultMessage result_message;
64 std::unique_ptr<google::protobuf::Closure> callback(
65 google::protobuf::NewPermanentCallback<
67 ::google::protobuf::uint32,
83 catch (std::exception
const& x)
85 using namespace std::literals::string_literals;
86 result_message.set_error(
"Error processing request: "s +
87 x.what() +
"\nInternal error details: " + boost::diagnostic_information(x));
88 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:77
Definition: authority.h:35
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:48
const ::std::string & parameters() const
Definition: template_protobuf_message_processor.h:42
::google::protobuf::MessageLite * type
Definition: template_protobuf_message_processor.h:43