ADTF  3.18.2
json_rpc_impl.h
Go to the documentation of this file.
1 
15 #ifndef PKG_RPC_DETAIL_JSON_RPC_IMPL_H_INCLUDED
16 #define PKG_RPC_DETAIL_JSON_RPC_IMPL_H_INCLUDED
17 
18 #include <rpc/json_rpc.h>
19 
20 namespace rpc {
21 
22 template <typename Stub, typename Connector, typename ConnectorInitializer>
24  const ConnectorInitializer& oInitializer)
25  : Connector(oInitializer), Stub(*static_cast<jsonrpc::IClientConnector*>(this))
26 {
27 }
28 
29 template <typename Stub, typename Connector, typename ConnectorInitializer>
31 {
32  return *const_cast<Stub*>(static_cast<const Stub*>(this));
33 }
34 
35 template <typename Stub, typename Interface, typename Connector, typename ConnectorInitializer>
37  jsonrpc_remote_interface(const ConnectorInitializer& oInitializer)
38  : jsonrpc_remote_object<Stub, Connector, ConnectorInitializer>(oInitializer)
39 {
40 }
41 
42 template <typename Stub, typename Interface, typename Connector, typename ConnectorInitializer>
44  const
45 {
46  return *const_cast<Stub*>(static_cast<const Stub*>(this));
47 }
48 
49 template <typename ServerStub, typename Connector>
51  : ServerStub(*static_cast<jsonrpc::AbstractServerConnector*>(this))
52 {
53 }
54 
55 template <typename ServerStub, typename Connector>
57  const char* strRequest, size_t nRequestSize, IResponse& oResponse)
58 {
59  try {
60  std::string strRequestHelper(strRequest, nRequestSize);
61  if (!Connector::OnRequest(strRequestHelper, &oResponse)) {
62  return InvalidCall;
63  }
64  }
65  catch (...) {
66  return FatalError;
67  }
68 
69  return {};
70 }
71 
72 } // namespace rpc
73 
74 #endif // PKG_RPC_DETAIL_JSON_RPC_IMPL_H_INCLUDED
A common result class usable as return value throughout.
Interface for returning a response to a remote call.
Definition: rpc_server.h:34
virtual a_util::result::Result HandleCall(const char *strRequest, size_t nRequestSize, IResponse &oResponse)
Handles an RPC call.
Definition: json_rpc_impl.h:56
Stub & GetStub() const
Access the rpc stub.
Definition: json_rpc_impl.h:43
jsonrpc_remote_interface(const ConnectorInitializer &oInitializer)
Constructor.
Definition: json_rpc_impl.h:37
Template for direct usage of the stub methods.
Definition: json_rpc.h:77
Stub & GetStub() const
Access the rpc stub.
Definition: json_rpc_impl.h:30
jsonrpc_remote_object(const ConnectorInitializer &oInitializer)
Constructor.
Definition: json_rpc_impl.h:23
RPC Protocol declaration.