hmbdc
simplify-high-performance-messaging-programming
Transport.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 
4 #include "hmbdc/app/Config.hpp"
5 
6 #include <memory>
7 #include <string>
8 
9 namespace hmbdc { namespace tips { namespace rnetmap {
10 
11 namespace transport_detail {
12 
13 struct Transport {
14  using ptr = std::shared_ptr<Transport>;
15 
16  Transport(hmbdc::app::Config const& cfg)
17  : config_(cfg)
18  , mtu_(config_.getExt<size_t>("mtu")) {
19  mtu_ -= (8u + 20u); // 8bytes udp header and 20bytes ip header
20  }
21 
22  bool operator == (Transport const& other ) const {
23  return &config_ == &other.config_;
24  }
25 
26  bool operator < (Transport const& other ) const {
27  return &config_ < &other.config_;
28  }
29 
30  virtual ~Transport(){}
31 
32 protected:
33  hmbdc::app::Config const config_;
34  size_t mtu_;
35 };
36 
39  : Transport(cfg) {
40  cfg (hmbdcName_, "hmbdcName")
41  (schedPolicy_, "schedPolicy")
42  (schedPriority_, "schedPriority")
43  ;
44  }
45 
46  char const* hmbdcName() const {
47  return this->hmbdcName_.c_str();
48  }
49 protected:
50  std::string hmbdcName_;
51  std::string schedPolicy_;
52  int schedPriority_;
53 };
54 
55 } //transport_detail
56 
59 }}}
class to hold an hmbdc configuration
Definition: Config.hpp:44
Definition: Base.hpp:12