MADARA  3.4.1
BasicASIOTransport.h
Go to the documentation of this file.
1 #ifndef _MADARA_BASIC_ASIO_TRANSPORT_H_
2 #define _MADARA_BASIC_ASIO_TRANSPORT_H_
3 
4 #include <string>
5 
6 #include "madara/MadaraExport.h"
15 #include "madara/Boost.h"
16 
17 namespace madara
18 {
19 namespace transport
20 {
21 namespace asio = boost::asio;
22 namespace ip = boost::asio::ip;
24 
25 class MADARA_EXPORT BasicASIOTransport : public Base
26 {
27 public:
30 
31  ~BasicASIOTransport() = 0;
32 
33  void close() override;
34 
35  int setup() override;
36 
37  static const double default_read_hertz;
38 
39  inline const std::vector<udp::endpoint>& get_udp_endpoints(void)
40  {
41  return addresses_;
42  }
43 
44 protected:
45  virtual int setup_socket(udp::socket& socket);
46  virtual int setup_read_socket();
47  virtual int setup_write_socket();
48  virtual int setup_sockets();
49 
50  virtual int setup_read_threads();
51  virtual int setup_read_thread(double hertz, const std::string& name) = 0;
52 
55 
57  asio::io_service io_service_;
58 
61 
63  std::vector<udp::endpoint> addresses_;
64 
66  udp::socket socket_{io_service_};
67 
68  friend class UdpTransportReadThread;
70 };
71 }
72 }
73 
74 #endif
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
This class stores variables and their values for use by any entity needing state information in a thr...
Starts threads with first class support of MADARA contexts.
Definition: Threader.h:36
Base class from which all transports must be derived.
Definition: Transport.h:46
threads::Threader read_threads_
threads for reading knowledge updates
virtual int setup_read_thread(double hertz, const std::string &name)=0
const std::vector< udp::endpoint > & get_udp_endpoints(void)
std::vector< udp::endpoint > addresses_
holds all multicast addresses we are sending to
knowledge::KnowledgeBase knowledge_
knowledge base for threads to use
asio::io_service io_service_
Boost::ASIO IO context.
Thread for reading knowledge updates through a Multicast datagram socket.
Holds basic transport settings.
Thread for reading knowledge updates through a UDP socket.
constexpr string_t string
boost::asio::ip::udp udp
Copyright(c) 2020 Galois.