MADARA  3.2.3
TransportSettings.h
Go to the documentation of this file.
1 #ifndef _MADARA_TRANSPORT_SETTINGS_H_
2 #define _MADARA_TRANSPORT_SETTINGS_H_
3 
16 #include <string>
17 #include <sstream>
18 #include <vector>
19 #include <map>
20 #include <ostream>
21 
22 #include "madara/LockType.h"
27 #include "madara/MadaraExport.h"
29 
30 namespace madara
31 {
32  namespace transport
33  {
34  // forward declare for friending
35  class Base;
36 
37  enum Types {
39  SPLICE = 1,
40  NDDS = 2,
41  TCP = 3,
42  UDP = 4,
43  MULTICAST = 5,
44  BROADCAST = 6,
47  ZMQ = 9
48  };
49 
53  };
54 
55  enum Messages {
56  ASSIGN = 0,
57  OPERATION = 1,
59  REGISTER = 3,
60  LATENCY = 10,
63  VOTE = 20
64  };
65 
71  MADARA_EXPORT std::string types_to_string (int id);
72 
76  class MADARA_EXPORT TransportSettings
77  {
78  public:
79  // allow transport::Base to alter private/protected members
80  friend class Base;
81 
83  #define DEFAULT_DOMAIN "KaRL"
84 
85  typedef std::vector <std::string> Voters;
86 
89  static const uint32_t DEFAULT_QUEUE_LENGTH = 500000;
90 
92  static const uint32_t DEFAULT_DEADLINE = 0;
93 
95  static const uint32_t DEFAULT_TRANSPORT = NO_TRANSPORT;
96 
98  static const uint32_t DEFAULT_RELIABILITY = RELIABLE;
99 
103  #define DEFAULT_ID 0
104 
108  #define DEFAULT_PROCESSES 1
109 
113  #define MAXIMUM_RESEND_ATTEMPTS 10
114 
116  TransportSettings ();
117 
119  TransportSettings (const TransportSettings & settings);
120 
121  virtual ~TransportSettings ();
122 
124  void operator= (const TransportSettings & settings);
125 
130  void add_read_domain (const std::string domain);
131 
135  void clear_read_domains (void);
136 
141  void get_read_domains (std::vector<std::string> & domains) const;
142 
148  bool is_reading_domain (const std::string domain) const;
149 
154  size_t num_read_domains (void) const;
155 
161  virtual void load (const std::string & filename,
162  const std::string & prefix = "transport");
163 
169  virtual void load_text (const std::string & filename,
170  const std::string & prefix = "transport");
171 
177  virtual void save (const std::string & filename,
178  const std::string & prefix = "transport") const;
179 
185  virtual void save_text (const std::string & filename,
186  const std::string & prefix = "transport") const;
187 
189 
194 
196  uint32_t read_threads;
197 
207  uint32_t queue_length;
208 
210  uint32_t type;
211 
214 
217 
227 
230  uint32_t reliability;
231 
234  uint32_t id;
235 
238  uint32_t processes;
239 
242 
245 
248 
251 
254 
256  double slack_time;
257 
263 
270  std::vector <std::string> hosts;
271 
276 
281 
282  private:
283 
287  std::map <std::string, int> read_domains_;
288  };
289 
290  inline std::string
291  type_name (const TransportSettings & settings)
292  {
293  std::string name = "none";
294 
295  switch (settings.type)
296  {
297  case 0:
298  name = "None";
299  break;
300  case 1:
301  name = "PrismTech DDS";
302  break;
303  case 2:
304  name = "RTI DDS";
305  break;
306  case 3:
307  name = "TCP (unsupported)";
308  break;
309  case 4:
310  name = "UDP Unicast";
311  break;
312  case 5:
313  name = "UDP Multicast";
314  break;
315  case 6:
316  name = "UDP Broadcast";
317  break;
318  case 7:
319  name = "UDP P2P Registry Server";
320  break;
321  case 8:
322  name = "UDP P2P Registry Client";
323  break;
324  case 9:
325  name = "ZeroMQ Pub/Sub";
326  break;
327  }
328 
329  return name;
330  }
331  }
332 }
333 
334 #include "TransportSettings.inl"
335 
336 #endif // _MADARA_TRANSPORT_SETTINGS_H_
OriginatorFragmentMap fragment_map
map of fragments received by originator
uint32_t fragment_queue_length
Indicates queue length for holding clock-keyed fragments.
std::vector< std::string > hosts
Host information for transports that require it.
double read_thread_hertz
number of valid messages allowed to be received per second.
Holds basic transport settings.
uint32_t type
Type of transport. See madara::transport::Types for options.
uint32_t id
the id of this process.
std::map< std::string, ClockFragmentMap > OriginatorFragmentMap
Map of originator to a map of clocks to fragments.
static struct madara::knowledge::tags::string_t string
uint32_t processes
number of processes expected in the network (best to overestimate if building latency tables ...
bool no_receiving
if true, never receive over transport
std::map< std::string, int > read_domains_
Any acceptable read domain is added here.
std::string write_domain
All class members are accessible to users for easy setup.
MADARA_EXPORT std::string types_to_string(int id)
Converts a transport type enum to a string equivalent.
bool no_sending
if true, never send over transport
bool send_reduced_message_header
send the reduced message header (clock, size, updates, KaRL id)
std::string on_data_received_logic
logic to be evaluated after every successful update
double slack_time
time to sleep between sends and rebroadcasts
uint32_t read_threads
the number of read threads to start
uint32_t queue_length
Length of the buffer used to store history of events.
std::vector< std::string > Voters
uint32_t reliability
Reliability required of the transport.
Copyright (c) 2015 Carnegie Mellon University.
Base class from which all transports must be derived.
Definition: Transport.h:45
bool never_exit
prevent MADARA from exiting on fatal errors and invalid state
uint32_t max_fragment_size
Maximum allowed fragment size for partitioning large messages.
std::string type_name(const TransportSettings &settings)
int resend_attempts
Maximum number of attempts to resend if transport is busy.
bool delay_launch
delay launching transports