Hazelcast C++ Client
Hazelcast C++ Client Library
member.h
1 /*
2  * Copyright (c) 2008-2022, 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 <unordered_map>
19 #include <functional>
20 #include <memory>
21 
22 #include "hazelcast/client/address.h"
23 #include <boost/uuid/uuid.hpp>
24 #include <ostream>
25 
26 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
27 #pragma warning(push)
28 #pragma warning(disable : 4251) // for dll export
29 #endif
30 
31 namespace hazelcast {
32 namespace client {
33 struct HAZELCAST_API endpoint_qualifier
34 {
35  int32_t type;
36  std::string identifier;
37 
38  friend bool HAZELCAST_API operator==(const endpoint_qualifier& lhs,
39  const endpoint_qualifier& rhs);
40 };
41 } // namespace client
42 } // namespace hazelcast
43 
44 namespace std {
45 template<>
46 struct HAZELCAST_API hash<hazelcast::client::endpoint_qualifier>
47 {
48  std::size_t operator()(
49  const hazelcast::client::endpoint_qualifier& qualifier) const noexcept;
50 };
51 } // namespace std
52 
53 namespace hazelcast {
54 namespace client {
61 class HAZELCAST_API member
62 {
63 public:
69  {
70  PUT = 1,
71  REMOVE = 2
72  };
73 
74  struct HAZELCAST_API version
75  {
76  byte major;
77  byte minor;
78  byte patch;
79 
80  bool operator==(const version& rhs) const;
81 
82  bool operator!=(const version& rhs) const;
83 
84  bool operator<(const version& rhs) const;
85 
86  bool operator>(const version& rhs) const;
87 
88  bool operator<=(const version& rhs) const;
89 
90  bool operator>=(const version& rhs) const;
91 
92  friend std::ostream HAZELCAST_API &
93  operator<<(std::ostream& os, const version& version);
94  };
95 
96  member();
97 
98  member(address member_address,
99  boost::uuids::uuid uuid,
100  bool lite,
101  std::unordered_map<std::string, std::string> attr,
102  std::unordered_map<endpoint_qualifier, address> address_map,
103  version v = { 0, 0, 0 });
104 
105  member(address member_address);
106 
107  member(boost::uuids::uuid uuid);
108 
109  friend bool HAZELCAST_API operator==(const member& lhs, const member& rhs);
110 
116  bool is_lite_member() const;
117 
123  const address& get_address() const;
124 
130  boost::uuids::uuid get_uuid() const;
131 
132  const std::unordered_map<std::string, std::string>& get_attributes() const;
133 
142  const std::string* get_attribute(const std::string& key) const;
143 
153  version get_version() const;
154 
161  bool lookup_attribute(const std::string& key) const;
162 
163  const std::unordered_map<endpoint_qualifier, address>& address_map() const;
164 
165  bool operator<(const member& rhs) const;
166 
167 private:
168  address address_;
169  boost::uuids::uuid uuid_;
170  bool lite_member_;
171  std::unordered_map<std::string, std::string> attributes_;
172  std::unordered_map<endpoint_qualifier, address> address_map_;
173  version version_;
174 };
175 
176 std::ostream HAZELCAST_API&
177 operator<<(std::ostream& out, const member& member);
178 } // namespace client
179 } // namespace hazelcast
180 
181 namespace std {
182 template<>
183 struct HAZELCAST_API hash<hazelcast::client::member>
184 {
185  std::size_t operator()(const hazelcast::client::member& k) const noexcept;
186 };
187 } // namespace std
188 
189 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
190 #pragma warning(pop)
191 #endif
Represents an address of a client or member in the cluster.
Definition: address.h:37
hz_cluster member class.
Definition: member.h:62
member_attribute_operation_type
PUT even type representing an addition of an attribute REMOVE event type representing a deletion of a...
Definition: member.h:69