RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
request.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_DATATASK_REQUEST_HPP
14#define RTCTK_DATATASK_REQUEST_HPP
15
16#include <future>
17
18namespace rtctk::dataTask {
19
20// TODO: reply code by std::error_code
25template <typename REQ_TYPE>
26class [[deprecated]] Request {
27public:
28 explicit Request(const REQ_TYPE& req_payload)
29 : m_req_payload(req_payload), m_rep_promise(std::make_shared<std::promise<void>>()) {
30 }
31
32 Request(const Request& r) = default;
33
34 Request& operator=(const Request& r) = default;
35
36 const REQ_TYPE& GetPayload() const {
37 return m_req_payload;
38 }
39
40 std::future<void> GetReplyFuture() const {
41 return m_rep_promise->get_future();
42 }
43
44 void SetReply() const {
45 m_rep_promise->set_value();
46 }
47
48 // template <class T>
49 // void SetException(const T& e) const {
50 // m_rep_promise->set_exception(boost::copy_exception(e));
51 // }
52
53private:
54 REQ_TYPE m_req_payload; // Payload associated to the request.
55 std::shared_ptr<std::promise<void>>
56 m_rep_promise; // Pointer to the promise associated to the reply.
57};
58
59} // namespace rtctk::dataTask
60
61#endif // RTCTK_DATATASK_REQUEST_HPP
Definition: request.hpp:26
Request(const REQ_TYPE &req_payload)
Definition: request.hpp:28
Request(const Request &r)=default
Request & operator=(const Request &r)=default
void SetReply() const
Definition: request.hpp:44
const REQ_TYPE & GetPayload() const
Definition: request.hpp:36
std::future< void > GetReplyFuture() const
Definition: request.hpp:40
Definition: computationBase.hpp:33