hmbdc
simplify-high-performance-messaging-programming
Topic.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 #include "hmbdc/text/TypedString.hpp"
4 #include <string>
5 
6 namespace hmbdc { namespace comm {
7 
8 extern char const TOPIC[6];
9 /**
10  * @brief topic as in the publish / subscribe communication paradigm
11  * @details recommended allowed letters are [a-z] [A-Z] [0-9] and /
12  * it has a length limit of 64 char including the terminal char
13  */
14 struct Topic : hmbdc::text::TypedString<TOPIC, 64u> {
15  /**
16  * @brief construct an empty topic
17  */
19  : TypedString()
20  {}
21 
22  /**
23  * @brief ctor from a char* string
24  * @details truncated to be 64 char
25  *
26  * @param t topic string limited to 64 char
27  */
28  Topic(char const* t)
29  : TypedString(t)
30  {}
31 
32  /**
33  * @brief ctor from a std string
34  * @details truncated to be 64 char
35  *
36  * @param t topic string limited to 64 char
37  */
38  Topic(std::string t)
39  : TypedString(t)
40  {}
41 };
42 }}
43 
44 namespace std {
45  template<>
46  struct hash<hmbdc::comm::Topic> : hash<hmbdc::text::TypedString<hmbdc::comm::TOPIC, 64u>>
47  {};
48 };
Topic(std::string t)
ctor from a std string
Definition: Topic.hpp:38
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: Topic.hpp:44
Definition: TypedString.hpp:17
Topic(char const *t)
ctor from a char* string
Definition: Topic.hpp:28
Topic()
construct an empty topic
Definition: Topic.hpp:18
Definition: Base.hpp:13