hmbdc
simplify-high-performance-messaging-programming
Protocol.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 #include "hmbdc/tips/netmap/SendTransportEngine.hpp"
4 #include "hmbdc/tips/netmap/RecvTransportEngine.hpp"
5 #include "hmbdc/tips/netmap/DefaultUserConfig.hpp"
6 #include "hmbdc/app/Config.hpp"
7 
8 #include "hmbdc/pattern/GuardedSingleton.hpp"
9 #include <algorithm>
10 namespace hmbdc { namespace tips { namespace netmap {
11 
12 struct Protocol
14  static constexpr char const* name() { return "netmap"; }
15  static constexpr auto dftConfig() { return DefaultUserConfig; }
17 
18  template <typename Buffer, typename>
20 
21  std::string getTipsDomainName(app::Config cfg) {
22  cfg.resetSection("tx", false);
23  cfg.setAdditionalFallbackConfig(app::Config(DefaultUserConfig));
24 
25  auto res= cfg.getExt<std::string>("ifaceAddr") + '-' + cfg.getExt<std::string>("netmapPort");
26  std::replace(res.begin(), res.end(), '/', ':');
27  return res;
28  }
29 
30  private:
32  Protocol() {}
33 };
34 
35 }}}
36 
37 
T getExt(const path_type &param, bool throwIfMissing=true) const
get a value from the config
Definition: Config.hpp:238
power a netmap port sending functions
Definition: SendTransportEngine.hpp:46
class to hold an hmbdc configuration
Definition: Config.hpp:45
void setAdditionalFallbackConfig(Config const &c)
set additional defaults
Definition: Config.hpp:154
Definition: RecvTransportEngine.hpp:32
Config & resetSection(char const *section, bool sectionExists=true)
change section name
Definition: Config.hpp:177
base for the Singleton that works with SingletonGuardian
Definition: GuardedSingleton.hpp:53
RAII representing the lifespan of the underlying Singleton which also ganrantees the singularity of u...
Definition: GuardedSingleton.hpp:20
Definition: Protocol.hpp:12
Definition: Base.hpp:12