47 #ifndef _MIRA_RPCFUTURE_H_ 48 #define _MIRA_RPCFUTURE_H_ 51 #include <boost/noncopyable.hpp> 52 #include <boost/thread/future.hpp> 121 template<
typename Duration>
123 return mFuture.timed_wait(relTime);
134 return mFuture.timed_wait_until(absTime);
172 template <
typename R>
180 const std::string&
callId) :
201 #if BOOST_VERSION > 105600 202 typedef typename boost::detail::shared_state<R>::move_dest_type
ReturnValue;
204 typedef typename boost::detail::future_traits<R>::move_dest_type
ReturnValue;
225 ReturnValue
get(
bool throwXRPC =
true,
bool recursive =
true)
258 const std::string&
callId) :
289 void get(
bool throwXRPC =
true,
bool recursive =
true)
322 const std::string&
callId) :
354 return this->
mFuture.get().getResult();
357 return this->
mFuture.get().getResult();
375 return this->
mFuture.get().response;
380 if (!this->
mFuture.has_value())
bool hasException()
Definition: RPCFuture.h:378
bool timedWait(Duration const &relTime) const
Waits and blocks the current thread until the result of the associated RPC call is ready...
Definition: RPCFuture.h:122
RPCFuture(RPCFuture &&other) noexcept
move constructor
Definition: RPCFuture.h:329
RPCFuture(boost::unique_future< JSONRPCResponse > other, AbstractRPCClient *client, const std::string &callId)
internally used by RPCClient
Definition: RPCFuture.h:321
RPCFuture()
Definition: RPCFuture.h:176
RPCFuture & operator=(RPCFuture &&other) noexcept
move assignment operator
Definition: RPCFuture.h:334
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.
RPCFutureCommon()
Definition: RPCFuture.h:72
bool hasException() const
Returns true if the RPC call associated with this future has finished with an exception rather than a...
Definition: RPCFuture.h:98
bool timedWaitUntil(boost::system_time const &absTime) const
Waits and blocks the current thread until the result of the associated RPC call is ready...
Definition: RPCFuture.h:133
RPCFutureCommon(AbstractRPCClient *client, const std::string &callId)
Definition: RPCFuture.h:74
An RPCFuture is a proxy for the result of an asynchronous RPC call.
Definition: RPCFuture.h:173
virtual void onDestructFuture(const std::string &callId)=0
Is called in the destructor of each RPCFuture to inform the client that we are no longer waiting for ...
void wait() const
Waits and blocks the current thread until the result of the associated RPC call is ready...
Definition: RPCFuture.h:111
bool hasOrigException()
Definition: RPCError.h:108
Wraps a JSON RPC call response.
Definition: JSONRPCResponse.h:61
Abstract interface for RPCClient.
Abstract interface for RPCClient.
Definition: AbstractRPCClient.h:60
An exception that is thrown by the RPCServer if an RPC call fails.
Definition: RPCError.h:76
~RPCFutureCommon()
Definition: RPCFuture.h:77
std::string mCallId
Definition: RPCFuture.h:147
Use this class to represent time durations.
Definition: Time.h:106
AbstractRPCClient * mClient
Definition: RPCFuture.h:146
Special response type for JSON RPC calls.
Wrapper for boost::unique_future that is specialized for RPC processing.
Definition: RPCFuture.h:68
RPCFuture & operator=(RPCFuture &&other) noexcept
move assignment operator
Definition: RPCFuture.h:192
json_spirit::mValue Value
A value is an abstract description of data in JSON (underlying data can either be one of the JSON bas...
Definition: JSON.h:176
RPCFuture(boost::unique_future< R > other, AbstractRPCClient *client, const std::string &callId)
internally used by RPCClient
Definition: RPCFuture.h:179
bool isReady() const
Checks to see if the result of the RPC call associated with this future is set.
Definition: RPCFuture.h:92
RPCFuture()
Definition: RPCFuture.h:318
RPCFuture(RPCFuture &&other) noexcept
move constructor
Definition: RPCFuture.h:265
const std::string & callId()
query call ID
Definition: RPCFuture.h:87
RPCFuture()
Definition: RPCFuture.h:254
void raiseOrigException(bool recursive=false)
Definition: RPCError.h:109
RPCFuture & operator=(RPCFuture &&other) noexcept
move assignment operator
Definition: RPCFuture.h:270
bool hasValue() const
Returns true if the RPC call associated with this future has finished with a return value value rathe...
Definition: RPCFuture.h:104
RPCFuture(RPCFuture &&other) noexcept
move constructor
Definition: RPCFuture.h:187
RPCFuture(boost::unique_future< void > other, AbstractRPCClient *client, const std::string &callId)
internally used by RPCClient
Definition: RPCFuture.h:257
boost::unique_future< R > mFuture
Definition: RPCFuture.h:148
boost::detail::future_traits< R >::move_dest_type ReturnValue
The rvalue return value, which essentially can be thought of R&&.
Definition: RPCFuture.h:204
void swap(RPCFutureCommon< R > &other)
Swaps ownership of the asynchronous results associated with other and *this.
Definition: RPCFuture.h:138
json::Value getAnswer()
Waits until the call has finished and returns the complete json rpc answer containing call id...
Definition: RPCFuture.h:373