MADARA  3.4.1
TransportContext.h
Go to the documentation of this file.
1 #ifndef _MADARA_TRANSPORT_CONTEXT_H_
2 #define _MADARA_TRANSPORT_CONTEXT_H_
3 
4 #include "madara/MadaraExport.h"
6 #include <time.h>
7 #include <string>
9 
10 namespace madara
11 {
12 namespace transport
13 {
19 class MADARA_EXPORT TransportContext
20 {
21 public:
23  {
24  IDLE_OPERATION = 0,
25  SENDING_OPERATION = 1,
26  RECEIVING_OPERATION = 2,
27  REBROADCASTING_OPERATION = 3
28  };
29 
33  TransportContext(int64_t operation = IDLE_OPERATION,
34  uint64_t receive_bandwidth = 0, uint64_t send_bandwidth = 0,
35  uint64_t message_time = 0, uint64_t current_time = utility::get_time(),
36  const std::string& domain = "", const std::string& originator = "",
37  const std::string& endpoint = "");
38 
44 
49 
54  void operator=(const TransportContext& rhs);
55 
59  void clear_records(void);
60 
66  int64_t get_operation(void) const;
67 
72  void set_operation(int64_t operation);
73 
78  uint64_t get_receive_bandwidth(void) const;
79 
84  uint64_t get_send_bandwidth(void) const;
85 
90  void set_receive_bandwidth(uint64_t bandwidth);
91 
96  void set_send_bandwidth(uint64_t bandwidth);
97 
105  uint64_t get_message_time(void) const;
106 
111  uint64_t get_current_time(void) const;
112 
120  void set_message_time(uint64_t message_time);
121 
126  void set_current_time(uint64_t current_time);
127 
134  void add_record(
135  const std::string& key, const madara::knowledge::KnowledgeRecord& record);
136 
141  const knowledge::KnowledgeMap& get_records(void) const;
142 
147  const std::string& get_domain(void) const;
148 
153  void set_domain(const std::string& domain);
154 
159  const std::string& get_originator(void) const;
160 
165  void set_originator(const std::string& originator);
166 
174  const std::string& get_endpoint(void) const;
175 
183  void set_endpoint(const std::string& endpoint);
184 
189  void set_records(const knowledge::KnowledgeMap& source);
190 
191 private:
195  int64_t operation_;
196 
201 
205  uint64_t send_bandwidth_;
206 
210  uint64_t message_time_;
211 
215  uint64_t current_time_;
216 
221 
226 
236 
241 };
242 }
243 }
244 
245 #include "TransportContext.inl"
246 
247 #endif // _MADARA_TRANSPORT_CONTEXT_H_
This class encapsulates an entry in a KnowledgeBase.
Provides context about the transport.
std::string domain_
Networking domain.
int64_t operation_
Operation being performed.
uint64_t receive_bandwidth_
Bandwidth being utilized for receive operations.
uint64_t message_time_
Message timestamp.
std::string originator_
Originator of the current message.
knowledge::KnowledgeMap records_
Context specific records.
std::string endpoint_
Public endpoint of the current message.
uint64_t current_time_
Current timestamp.
uint64_t send_bandwidth_
Bandwidth being utilized for send operations.
constexpr string_t string
::std::map< std::string, KnowledgeRecord > KnowledgeMap
int64_t get_time(void)
Returns a time of day in nanoseconds If simtime feature is enabled, this may be simulation time inste...
Definition: Utility.inl:265
Copyright(c) 2020 Galois.