Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
message.h
1/*
2 * Copyright (c) 2008-2025, Hazelcast, Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <utility>
19
20#include "hazelcast/client/serialization/serialization.h"
21
22#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
23#pragma warning(push)
24#pragma warning(disable : 4251) // for dll export
25#endif
26
27namespace hazelcast {
28namespace client {
29class member;
30
31namespace topic {
32class HAZELCAST_API message
33{
34public:
35 message(const std::string& topic_name,
36 typed_data&& msg,
37 int64_t publish_time,
38 boost::optional<member>&& member)
39 : message(topic_name,
40 std::move(msg),
41 std::chrono::system_clock::from_time_t(
42 std::chrono::duration_cast<std::chrono::seconds>(
43 std::chrono::milliseconds(publish_time))
44 .count()),
45 std::move(member))
46 {}
47
48 message(std::string topic_name,
49 typed_data&& msg,
50 std::chrono::system_clock::time_point publish_time,
51 boost::optional<member>&& member)
52 : message_object_(msg)
53 , publish_time_(publish_time)
54 , publishing_member_(member)
55 , name_(std::move(topic_name))
56 {}
57
58 const typed_data& get_message_object() const { return message_object_; }
59
60 std::chrono::system_clock::time_point get_publish_time() const
61 {
62 return publish_time_;
63 }
64
65 const member* get_publishing_member() const
66 {
67 return publishing_member_.get_ptr();
68 }
69
70 const std::string& get_source() const { return name_; }
71
72 const std::string& get_name() const { return name_; }
73
74private:
75 typed_data message_object_;
76 std::chrono::system_clock::time_point publish_time_;
77 boost::optional<member> publishing_member_;
78 std::string name_;
79};
80} // namespace topic
81} // namespace client
82} // namespace hazelcast
83
84#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
85#pragma warning(pop)
86#endif
hz_cluster member class.
Definition member.h:62
typed_data class is a wrapper class for the serialized binary data.