WPILibC++  unspecified
RpcCall.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2017. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef NT_RPCCALL_H_
9 #define NT_RPCCALL_H_
10 
11 #include <string>
12 #include <utility>
13 
14 #include "ntcore_c.h"
15 
16 namespace nt {
17 
18 class NetworkTableEntry;
19 
21 class RpcCall final {
22  public:
26  RpcCall() : m_entry(0), m_call(0) {}
27 
33  RpcCall(NT_Entry entry, NT_RpcCall call)
34  : m_entry(entry), m_call(call) {}
35 
36  RpcCall(RpcCall&& other);
37  RpcCall(const RpcCall&) = delete;
38  RpcCall& operator=(const RpcCall&) = delete;
39 
43  ~RpcCall();
44 
49  explicit operator bool() const { return m_call != 0; }
50 
56 
61  NT_RpcCall GetCall() const { return m_call; }
62 
69  bool GetResult(std::string* result);
70 
79  bool GetResult(std::string* result, double timeout, bool* timed_out);
80 
84  void CancelResult();
85 
86  friend void swap(RpcCall& first, RpcCall& second) {
87  using std::swap;
88  swap(first.m_entry, second.m_entry);
89  swap(first.m_call, second.m_call);
90  }
91 
92  private:
93  NT_Entry m_entry;
94  NT_RpcCall m_call;
95 };
96 
97 } // namespace nt
98 
99 #include "networktables/RpcCall.inl"
100 
101 #endif // NT_RPCCALL_H_
RpcCall()
Construct invalid instance.
Definition: RpcCall.h:26
NetworkTables Remote Procedure Call.
Definition: RpcCall.h:21
bool GetResult(std::string *result)
Get the result (return value).
Definition: RpcCall.inl:24
NetworkTableEntry GetEntry() const
Get the RPC entry.
Definition: RpcCall.cpp:14
RpcCall(NT_Entry entry, NT_RpcCall call)
Construct from native handles.
Definition: RpcCall.h:33
Definition: IEntryNotifier.h:15
~RpcCall()
Destructor.
Definition: RpcCall.inl:19
void CancelResult()
Ignore the result.
Definition: RpcCall.inl:41
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
NT_RpcCall GetCall() const
Get the call native handle.
Definition: RpcCall.h:61