Hazelcast C++ Client
Hazelcast C++ Client Library
message.h
1 /*
2  * Copyright (c) 2008-2021, 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 
27 namespace hazelcast {
28  namespace client {
29  class member;
30 
31  namespace topic {
32  class HAZELCAST_API message {
33  public:
34  message(const std::string &topic_name, typed_data &&msg, int64_t publish_time,
35  boost::optional<member> &&member) : message(topic_name, std::move(msg),
36  std::chrono::system_clock::from_time_t(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::milliseconds(publish_time)).count()),
37  std::move(member)) {}
38 
39  message(std::string topic_name, typed_data &&msg, std::chrono::system_clock::time_point publish_time,
40  boost::optional<member> &&member)
41  : message_object_(msg), publish_time_(publish_time), publishing_member_(member), name_(std::move(topic_name)) {}
42 
43  const typed_data &get_message_object() const {
44  return message_object_;
45  }
46 
47  std::chrono::system_clock::time_point get_publish_time() const {
48  return publish_time_;
49  }
50 
51  const member *get_publishing_member() const {
52  return publishing_member_.get_ptr();
53  }
54 
55  const std::string &get_source() const {
56  return name_;
57  }
58 
59  const std::string &get_name() const {
60  return name_;
61  }
62 
63  private:
64  typed_data message_object_;
65  std::chrono::system_clock::time_point publish_time_;
66  boost::optional<member> publishing_member_;
67  std::string name_;
68  };
69  }
70  }
71 }
72 
73 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
74 #pragma warning(pop)
75 #endif
76 
hz_cluster member class.
Definition: member.h:39
typed_data class is a wrapper class for the serialized binary data.