hmbdc
simplify-high-performance-messaging-programming
Protocol.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 #include "hmbdc/tips/tcpcast/Messages.hpp"
4 #include "hmbdc/tips/tcpcast/SendTransportEngine.hpp"
5 #include "hmbdc/tips/tcpcast/RecvTransportEngine.hpp"
6 #include "hmbdc/tips/tcpcast/DefaultUserConfig.hpp"
7 #include "hmbdc/app/utils/NetContextUtil.hpp"
8 #include "hmbdc/app/Config.hpp"
9 
10 #include "hmbdc/pattern/GuardedSingleton.hpp"
11 
12 #include <algorithm>
13 
14 namespace hmbdc { namespace tips { namespace tcpcast {
15 
16 struct Protocol
17 : pattern::GuardedSingleton<Protocol>
19  static constexpr char const* name() { return "tcpcast"; }
20  static constexpr auto dftConfig() { return DefaultUserConfig; }
22  template <typename Buffer, typename AttachmentAllocator>
24  std::string getTipsDomainName(app::Config cfg) {
25  cfg.resetSection("tx", false);
26  cfg.setAdditionalFallbackConfig(app::Config(DefaultUserConfig));
27  auto res = cfg.getExt<std::string>("ifaceAddr") + '-' + cfg.getExt<std::string>("udpcastDests");
28  std::replace(res.begin(), res.end(), '/', ':');
29  return res;
30  }
31 
32  private:
34  Protocol(){
35  checkEpollTaskInitialization();
36  }
37 };
38 
39 }}}
40 
T getExt(const path_type &param, bool throwIfMissing=true) const
get a value from the config
Definition: Config.hpp:238
class to hold an hmbdc configuration
Definition: Config.hpp:45
void setAdditionalFallbackConfig(Config const &c)
set additional defaults
Definition: Config.hpp:154
Config & resetSection(char const *section, bool sectionExists=true)
change section name
Definition: Config.hpp:177
Definition: Protocol.hpp:16
Definition: NetContextUtil.hpp:10
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: SendTransportEngine.hpp:172
Definition: Base.hpp:12