Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
Address.h
1 /*
2  * Copyright (c) 2008-2017, 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 #ifndef HAZELCAST_ADDRESS
17 #define HAZELCAST_ADDRESS
18 
19 #include "hazelcast/util/HazelcastDll.h"
20 #include "hazelcast/client/serialization/IdentifiedDataSerializable.h"
21 
22 #include <string>
23 #include <sstream>
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 {
31  namespace client {
32 
36  class HAZELCAST_API Address : public serialization::IdentifiedDataSerializable {
37  public:
38  static const int ID;
39 
43  Address();
44 
48  Address(const std::string &url, int port);
49 
54  bool operator == (const Address &address) const;
55 
60  bool operator != (const Address &address) const;
61 
65  int getPort() const;
66 
70  const std::string& getHost() const;
71 
72  /***** serialization::IdentifiedDataSerializable interface implementation starts here *********************/
73  virtual int getFactoryId() const;
74 
75  virtual int getClassId() const;
76 
77  virtual void writeData(serialization::ObjectDataOutput &writer) const;
78 
79  virtual void readData(serialization::ObjectDataInput &reader);
80 
81  /***** serialization::IdentifiedDataSerializable interface implementation end here ************************/
82  private:
83  std::string host;
84  int port;
85  byte type;
86 
87  static const byte IPV4;
88  static const byte IPV6;
89  };
90 
94  struct HAZELCAST_API addressComparator {
100  bool operator ()(const Address &lhs, const Address &rhs) const;
101  };
102 
103  std::ostream HAZELCAST_API &operator << (std::ostream &stream, const Address &address);
104 
105  }
106 };
107 
108 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
109 #pragma warning(pop)
110 #endif
111 
112 #endif /* HAZELCAST_ADDRESS */
Provides serialization methods for primitive types,a arrays of primitive types, Portable, IdentifiedDataSerializable and custom serializables.
Definition: ObjectDataOutput.h:52
IP Address.
Definition: Address.h:36
Classes that will be used with hazelcast data structures like IMap, IQueue etc should either inherit ...
Definition: IdentifiedDataSerializable.h:42
Address comparator functor.
Definition: Address.h:94
Provides deserialization methods for primitives types, arrays of primitive types Portable, IdentifiedDataSerializable and custom serializable types.
Definition: ObjectDataInput.h:66