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 
25 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
26 #pragma warning(push)
27 #pragma warning(disable: 4251) //for dll export
28 #endif
29 
30 namespace hazelcast { namespace client {
31  struct HAZELCAST_API endpoint_qualifier {
32  int32_t type;
33  std::string identifier;
34 
35  friend bool HAZELCAST_API operator==(const endpoint_qualifier &lhs, const endpoint_qualifier &rhs);
36  };
37 }}
38 
39 namespace std {
40  template<>
41  struct HAZELCAST_API hash<hazelcast::client::endpoint_qualifier> {
42  std::size_t operator()(const hazelcast::client::endpoint_qualifier &qualifier) const noexcept;
43  };
44 }
45 
46 
47 namespace hazelcast {
48  namespace client {
55  class HAZELCAST_API member {
56  public:
62  PUT = 1,
63  REMOVE = 2
64  };
65 
66  struct version {
67  byte major;
68  byte minor;
69  byte patch;
70  };
71 
72  member();
73 
74  member(address member_address, boost::uuids::uuid uuid, bool lite,
75  std::unordered_map<std::string, std::string> attr,
76  std::unordered_map<endpoint_qualifier, address> address_map);
77 
78  member(address member_address);
79 
80  member(boost::uuids::uuid uuid);
81 
82  friend bool HAZELCAST_API operator==(const member &lhs, const member &rhs);
83 
89  bool is_lite_member() const;
90 
96  const address &get_address() const;
97 
103  boost::uuids::uuid get_uuid() const;
104 
105  const std::unordered_map<std::string, std::string> &get_attributes() const;
106 
115  const std::string *get_attribute(const std::string &key) const;
116 
123  bool lookup_attribute(const std::string &key) const;
124 
125  const std::unordered_map<endpoint_qualifier, address> &address_map() const;
126 
127  bool operator<(const member &rhs) const;
128 
129  private:
130  address address_;
131  boost::uuids::uuid uuid_;
132  bool lite_member_;
133  std::unordered_map<std::string, std::string> attributes_;
134  std::unordered_map<endpoint_qualifier, address> address_map_;
135  };
136 
137  std::ostream HAZELCAST_API &operator<<(std::ostream &out, const member &member);
138  }
139 }
140 
141 namespace std {
142  template<>
143  struct HAZELCAST_API hash<hazelcast::client::member> {
144  std::size_t operator()(const hazelcast::client::member &k) const noexcept;
145  };
146 }
147 
148 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
149 #pragma warning(pop)
150 #endif
151 
152 
153 
154 
Represents an address of a client or member in the cluster.
Definition: address.h:36
hz_cluster member class.
Definition: member.h:55
member_attribute_operation_type
PUT even type representing an addition of an attribute REMOVE event type representing a deletion of a...
Definition: member.h:61