1 #include "hmbdc/Copyright.hpp" 4 #include "hmbdc/comm/Topic.hpp" 5 #include "hmbdc/time/Time.hpp" 6 #include "hmbdc/app/Message.hpp" 13 #include <sys/types.h> 17 namespace hmbdc {
namespace app {
namespace tcpcast {
19 using namespace hmbdc;
33 } __attribute__((aligned (8)));
42 size_t map(
char const* fileName) {
47 fd = open(fileName, O_RDONLY);
49 len = (uint64_t)sb.st_size;
50 attachment = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
51 if (attachment == MAP_FAILED)
return 0;
54 string line(fileName);
55 auto pos = line.find_last_of(
'/');
56 if (pos == string::npos) pos = 0;
57 strncpy(file, line.c_str() + pos + 1,
sizeof(file));
62 munmap(attachment, len);
65 } __attribute__((aligned (8)));
70 uint16_t messagePayloadLen;
72 std::pair<char const*, char const*> topic()
const {
73 char const* b =
reinterpret_cast<const char*
>(
this)
75 return std::make_pair(b, b + topicLen);
78 void const* payload()
const {
79 return reinterpret_cast<const char*
>(
this)
84 return reinterpret_cast<char*
>(
this)
88 uint16_t typeTag()
const {
93 template <
typename Message>
99 template <
typename Message>
100 Message
const& wrapped()
const {
102 return wrap->payload;
105 size_t wireSize()
const {
110 size_t wireSizeContainsTopic()
const {
113 } __attribute__((packed));
132 , std::string
const& ipIn
137 , loopback(loopbackIn)
138 , timestamp(time::SysTime::now()) {
139 strncpy(ip, ipIn.c_str(),
sizeof(ip));
140 strncpy(topicRegex, topicRegexIn.c_str(),
sizeof(topicRegex));
141 topicRegex[
sizeof(topicRegex) - 1] = 0;
144 char topicRegex[128];
155 std::ostream& operator << (std::ostream& os,
SessionStarted const & m) {
156 return os <<
"Session to topic source started " << m.ip;
164 std::ostream& operator << (std::ostream& os,
SessionDropped const & m) {
165 return os <<
"Session to topic source dropped " << m.ip;
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: TypedString.hpp:74
Definition: Messages.hpp:122
Definition: Message.hpp:21
Definition: Messages.hpp:115
Definition: Messages.hpp:160
Definition: Messages.hpp:23
Definition: Message.hpp:25
Definition: Message.hpp:46
Definition: Messages.hpp:129
Definition: Messages.hpp:35
Definition: Client.hpp:11
Definition: Messages.hpp:151