RemoteProcedure< R, ARGUMENTS > Class Template Reference

#include <Pt/Remoting/RemoteProcedure.h>

Performs a remote procedure call. More...

Public Member Functions

 RemoteProcedure (Client &client, const std::string &name)
 Construct with procedure name and client.
 
virtual ~RemoteProcedure ()
 Destructor.
 
void begin (const ARGUMENTS &args...)
 Begins an asynchronous remote call.
 
const R & call (const ARGUMENTS &args...)
 Blocking remote call.
 
void cancel ()
 Cancels the remote call.
 
Clientclient ()
 Returns the client used for communication.
 
Signal< const Result< R > & > & finished ()
 Reports that the result has been received.
 
bool isFailed () const
 Returns true if the procedure failed.
 
const Stringname () const
 Returns the name of the procedure.
 
const R & operator() (const ARGUMENTS &args...)
 Blocking remote call.
 
Result< R > & result ()
 Returns the result of the call.
 
const Result< R > & result () const
 Returns the result of the call.
 

Detailed Description

template<typename R, typename... ARGUMENTS>
class Pt::Remoting::RemoteProcedure< R, ARGUMENTS >

This class is a function object to perform remote procedure call. It is a class template where the template parameters imply the signature of the remote procedure. The first tempate parameter is the return value type, followed by the argument types, if any. For example, a RemoteProcedure<double, int, int> calls a remote procedure which returns a double and takes two ints as arguments. A RemoteProcedure<std::string> calls a remote procedure without arguments, only returning a std::string.

Synchronous operation is supported by means of the operator() and the call() method. Asynchronous calls can be made by calling begin and connecting to the finished signal, which is sent when the result has been received. The finshed signal has one parameter of type Result<R>, which contains the return value.

The RemoteProcedure uses a Client for communication with the service. In many cases this will be a HttpClient, but other transport protocols can be supported by other types of clients. The Client must live longer than the remote procedures using it.