MADARA  3.2.3
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:
22 
23  enum Operations {
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 = "",
37  const std::string & originator = "",
38  const std::string & endpoint = "");
39 
44  TransportContext (const TransportContext & rhs);
45 
49  ~TransportContext ();
50 
55  void operator= (const TransportContext & rhs);
56 
60  void clear_records (void);
61 
67  int64_t get_operation (void) const;
68 
73  void set_operation (int64_t operation);
74 
79  uint64_t get_receive_bandwidth (void) const;
80 
85  uint64_t get_send_bandwidth (void) const;
86 
87 
92  void set_receive_bandwidth (uint64_t bandwidth);
93 
98  void set_send_bandwidth (uint64_t bandwidth);
99 
107  uint64_t get_message_time (void) const;
108 
113  uint64_t get_current_time (void) const;
114 
122  void set_message_time (uint64_t message_time);
123 
128  void set_current_time (uint64_t current_time);
129 
136  void add_record (const std::string & key,
137  const madara::knowledge::KnowledgeRecord & record);
138 
143  const knowledge::KnowledgeMap & get_records (void) const;
144 
149  const std::string & get_domain (void) const;
150 
155  void set_domain (const std::string & domain);
156 
161  const std::string & get_originator (void) const;
162 
167  void set_originator (const std::string & originator);
168 
176  const std::string & get_endpoint (void) const;
177 
185  void set_endpoint (const std::string & endpoint);
186 
191  void set_records (const knowledge::KnowledgeMap& source);
192 
193  private:
194 
198  int64_t operation_;
199 
204 
208  uint64_t send_bandwidth_;
209 
213  uint64_t message_time_;
214 
218  uint64_t current_time_;
219 
224 
229 
239 
244  };
245  }
246 }
247 
248 #include "TransportContext.inl"
249 
250 #endif // _MADARA_TRANSPORT_CONTEXT_H_
This class encapsulates an entry in a KnowledgeBase.
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:253
uint64_t send_bandwidth_
Bandwidth being utilized for send operations.
knowledge::KnowledgeMap records_
Context specific records.
std::string originator_
Originator of the current message.
Provides context about the transport.
int64_t operation_
Operation being performed.
static struct madara::knowledge::tags::string_t string
std::string endpoint_
Public endpoint of the current message.
::std::map< std::string, KnowledgeRecord > KnowledgeMap
uint64_t receive_bandwidth_
Bandwidth being utilized for receive operations.
uint64_t current_time_
Current timestamp.
std::string domain_
Networking domain.
Copyright (c) 2015 Carnegie Mellon University.
uint64_t message_time_
Message timestamp.