47 #ifndef _MIRA_BINARYRPCBACKEND_H_ 48 #define _MIRA_BINARYRPCBACKEND_H_ 51 #include <boost/thread/future.hpp> 65 in.deserialize(value);
66 promise.set_value(std::move(value));
75 template <u
int8 BinaryFormatVersion>
76 struct binaryRPCdeserializeHelper;
116 template <u
int8 BinaryFormatVersion>
161 MIRA_THROW(XRuntime,
"The buffer does not contain a valid binary response");
177 binaryRPCdeserializeHelper<BinaryFormatVersion>::deserialize(status, mIn);
183 binaryRPCreturnHelper(promise, mIn);
194 ex.addExternalStackInfo<
XRPC>(stack, thread);
202 ex.addInfo(
"There is no stack trace from the RPC method or it is unreadable.");
204 promise.set_exception(boost::copy_exception(ex));
210 MIRA_THROW(XLogical,
"Unknown return status.");
238 static uint32 sID = 0;
248 void setHeader(
const std::string& callId,
const std::string& service,
252 mOut.serialize(marker,
false);
254 mOut.serialize(callId);
255 mOut.serialize(service);
256 mOut.serialize(signature);
264 template <
typename P>
266 mOut.serialize(param);
297 mOut.serialize(marker,
false);
299 mOut.serialize(callId);
309 mOut.serialize(message);
321 mOut.serialize(message);
322 mOut.serialize(callstack);
323 mOut.serialize(getCurrentThreadID());
334 mOut.serialize(std::string(ex.
what()));
336 mOut.serialize(getCurrentThreadID());
388 void getHeader(std::string& oCallId, std::string& oService)
393 MIRA_THROW(XRuntime,
"The buffer does not contain a valid binary response");
406 return signature == mSignature;
422 template <
typename P>
440 template <u
int8 BinaryFormatVersion>
441 struct binaryRPCdeserializeHelper
452 struct binaryRPCdeserializeHelper<0>
459 std::string fulltypename;
460 deserializer.deserialize(fulltypename,
false);
462 assert(fulltypename ==
"mira::BinaryRPCBackend::ClientResponse::ReturnStatus");
464 deserializer.deserialize(status,
false);
void setHeader(const std::string &callId, const std::string &service, const RPCSignature &signature)
Write the request header consisting of the call ID, the service name and the signature of the request...
Definition: BinaryRPCBackend.h:248
ConcreteBinaryDeserializer< BinaryBufferIstream, 2 > BinaryBufferDeserializer
Typedef for BinaryDeserializer based on a Buffer.
Definition: BinarySerializer.h:1603
void getHeader(std::string &callId)
Read the response header (i.e.
Definition: BinaryRPCBackend.h:156
Definition: BinaryRPCBackend.h:145
Definition: BinarySerializer.h:324
void getParameter(P &oParam)
Read and deserializes the next parameter from the request.
Definition: BinaryRPCBackend.h:423
BinaryRPCBackendTempl< 2 > BinaryRPCBackend
Definition: BinaryRPCBackend.h:437
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Error codes for reasons of errors/exceptions while processing an rpc call.
Provides binary client and server side requests and responses.
Definition: BinaryRPCBackend.h:117
void returnVoid()
Write successful end of an RPC call.
Definition: BinaryRPCBackend.h:356
void setHeader(const std::string &callId)
Write the response header consisting of the ID of the call.
Definition: BinaryRPCBackend.h:294
Binary client-side request.
Definition: BinaryRPCBackend.h:228
uint32 ThreadID
Platform independent thread ID.
Definition: ThreadID.h:68
Buffer< uint8 > ContainerType
Definition: BinaryRPCBackend.h:126
BinaryRPCBackendTempl< 0 > BinaryRPCBackendLegacy
Definition: BinaryRPCBackend.h:436
ServerResponse(ContainerType *buffer)
Definition: BinaryRPCBackend.h:285
Binary server-side response.
Definition: BinaryRPCBackend.h:281
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
void getReturn(boost::promise< R > &promise)
Obtain return value from response and set it using promise.set_value() or set exception using promise...
Definition: BinaryRPCBackend.h:174
std::string toString(const T &value, int precision=-1)
Converts any data type to string (the data type must support the stream << operator).
Definition: ToString.h:256
void returnException(RPCError reason, const std::string &message)
Write exception as result of an RPC call.
Definition: BinaryRPCBackend.h:307
Binary server-side request.
Definition: BinaryRPCBackend.h:373
An exception that is thrown by the RPCServer if an RPC call fails.
Definition: RPCError.h:76
Binary serializer and deserializer.
void returnResult(const R &res)
Write result of an RPC call.
Definition: BinaryRPCBackend.h:346
const CallStack & callStack() const
Returns the state of the callstack at the moment when the exception was thrown.
Definition: Exception.h:257
ServerRequest(ContainerType *buffer)
Definition: BinaryRPCBackend.h:377
RPCError
enumeration of possible reasons for errors/exceptions while performing an RPC call ...
Definition: RPCError.h:64
void returnException(RPCError reason, SerializableException &ex)
Write exception as result of an RPC call.
Definition: BinaryRPCBackend.h:331
void returnException(RPCError reason, const std::string &message, const CallStack &callstack)
Write exception as result of an RPC call.
Definition: BinaryRPCBackend.h:317
const RPCSignature & getSignature()
Return the signature, that was read from the request header in the previous getHeader() call above...
Definition: BinaryRPCBackend.h:413
ReturnStatus
Definition: BinaryRPCBackend.h:142
Contains methods for simple atomic operations (such as increment, etc.) that are thread-safe without ...
void setOrigException(SerializableException *ex)
takes ownership of ex
Definition: RPCError.h:106
bool checkSignature(const RPCSignature &signature)
Check, if the passed signature is compatible with the signature that was read from the request header...
Definition: BinaryRPCBackend.h:404
ClientRequest(ContainerType *buffer)
Definition: BinaryRPCBackend.h:231
std::string generateCallID()
Generates a unique call ID for a client request of this backend.
Definition: BinaryRPCBackend.h:237
void getHeader(std::string &oCallId, std::string &oService)
Read the request header including the call ID, the service name and the signature of the method...
Definition: BinaryRPCBackend.h:388
void deserialize(T &value, bool enableTypeCheck=true, bool recursive=false)
Provides a special deserialize interface for the BinaryDeserializer.
Definition: BinarySerializer.h:1340
Encapsulates unix call stack functionality.
Definition: CallStack.h:86
ClientResponse(ContainerType *buffer)
Definition: BinaryRPCBackend.h:149
void setParameter(const P ¶m)
Write the value of the next parameter to the request.
Definition: BinaryRPCBackend.h:265
Definition: BinaryRPCBackend.h:144
virtual const char * what() const MIRA_NOEXCEPT_OR_NOTHROW
Returns the text of exception containing the information given in MIRA_THROW and MIRA_RETHROW as well...
Definition: BinaryRPCBackend.h:143
Stores the signature of an RPC method including the methods name and its parameter types...
Definition: RPCSignature.h:68
Definition: BinaryRPCBackend.h:123
Binary client-side response.
Definition: BinaryRPCBackend.h:139
uint32 inc(volatile uint32 *var)
Increments the value of the variable pointed to by var and returns its old value. ...
Definition: Atomic.h:82
Definition: Exceptions.h:85