Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
Address.h
1 /*
2  * Copyright (c) 2008-2015, 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 
59  int getPort() const;
60 
64  const std::string& getHost() const;
65 
66  /***** serialization::IdentifiedDataSerializable interface implementation starts here *********************/
67  virtual int getFactoryId() const;
68 
69  virtual int getClassId() const;
70 
71  virtual void writeData(serialization::ObjectDataOutput &writer) const;
72 
73  virtual void readData(serialization::ObjectDataInput &reader);
74 
75  /***** serialization::IdentifiedDataSerializable interface implementation end here ************************/
76  private:
77  std::string host;
78  int port;
79  byte type;
80 
81  static const byte IPV4;
82  static const byte IPV6;
83  };
84 
88  struct HAZELCAST_API addressComparator {
94  bool operator ()(const Address &lhs, const Address &rhs) const;
95  };
96 
97  std::ostream HAZELCAST_API &operator << (std::ostream &stream, const Address &address);
98 
99  }
100 };
101 
102 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
103 #pragma warning(pop)
104 #endif
105 
106 #endif /* HAZELCAST_ADDRESS */
Provides serialization methods for primitive types,a arrays of primitive types, Portable, IdentifiedDataSerializable and custom serializables.
Definition: ObjectDataOutput.h:51
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:88
Provides deserialization methods for primitives types, arrays of primitive types Portable, IdentifiedDataSerializable and custom serializable types.
Definition: ObjectDataInput.h:66