rpc.hpp 0.8.1
Simple RPC Header-Only Library
Public Member Functions | Protected Member Functions | List of all members
rpc_hpp::client::client_interface< Serial > Class Template Referenceabstract

Class defining an interface for calling into an RPC server or module. More...

#include <rpc.hpp>

Public Member Functions

 client_interface (const client_interface &)=delete
 
client_interfaceoperator= (const client_interface &)=delete
 
client_interfaceoperator= (client_interface &&)=delete
 
template<typename R = void, typename... Args>
call_func (std::string func_name, Args &&... args)
 Sends an RPC call request to a server, waits for a response, then returns the result. More...
 
template<typename R , typename... Args>
call_header_func_impl (R(*func)(Args...), std::string func_name, Args &&... args)
 Sends an RPC call request to a server, waits for a response, then returns the result. More...
 

Protected Member Functions

 client_interface (client_interface &&) noexcept=default
 
virtual void send (const typename Serial::bytes_t &bytes)=0
 Sends serialized data to a server or module. More...
 
virtual Serial::bytes_t receive ()=0
 Receives serialized data from a server or module. More...
 

Detailed Description

template<typename Serial>
class rpc_hpp::client::client_interface< Serial >

Class defining an interface for calling into an RPC server or module.

Template Parameters
Serialserial_adapter type that controls how objects are serialized/deserialized

Member Function Documentation

◆ call_func()

template<typename Serial >
template<typename R = void, typename... Args>
R rpc_hpp::client::client_interface< Serial >::call_func ( std::string  func_name,
Args &&...  args 
)
inline

Sends an RPC call request to a server, waits for a response, then returns the result.

Template Parameters
RReturn type of the remote function to call
ArgsVariadic argument type(s) of the remote function to call
Parameters
func_nameName of the remote function to call
argsArgument(s) for the remote function
Returns
R Result of the function call, will throw with server's error message if the result does not exist
Exceptions
client_send_errorThrown if error occurs during the send function
client_receive_errorThrown if error occurs during the receive function
Note
nodiscard because an expensive remote procedure call is being performed

◆ call_header_func_impl()

template<typename Serial >
template<typename R , typename... Args>
R rpc_hpp::client::client_interface< Serial >::call_header_func_impl ( R(*)(Args...)  func,
std::string  func_name,
Args &&...  args 
)
inline

Sends an RPC call request to a server, waits for a response, then returns the result.

Template Parameters
RReturn type of the remote function to call
ArgsVariadic argument type(s) of the remote function to call
Parameters
funcPointer to the function definition to deduce signature
func_nameName of the remote function to call
argsArgument(s) for the remote function
Returns
R Result of the function call, will throw with server's error message if the result does not exist
Note
nodiscard because an expensive remote procedure call is being performed

◆ receive()

template<typename Serial >
virtual Serial::bytes_t rpc_hpp::client::client_interface< Serial >::receive ( )
protectedpure virtual

Receives serialized data from a server or module.

Returns
Serial::bytes_t Received serialized data

◆ send()

template<typename Serial >
virtual void rpc_hpp::client::client_interface< Serial >::send ( const typename Serial::bytes_t &  bytes)
protectedpure virtual

Sends serialized data to a server or module.

Parameters
bytesSerialized data to be sent

The documentation for this class was generated from the following file: