Realistic 3D camera system
3D camera system components
basic_endpoint.hpp
Go to the documentation of this file.
1 //
2 // generic/basic_endpoint.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_GENERIC_BASIC_ENDPOINT_HPP
12 #define ASIO_GENERIC_BASIC_ENDPOINT_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
20 
22 
23 namespace asio {
24 namespace generic {
25 
27 
41 template <typename Protocol>
43 {
44 public:
46  typedef Protocol protocol_type;
47 
50 #if defined(GENERATING_DOCUMENTATION)
51  typedef implementation_defined data_type;
52 #else
54 #endif
55 
58  {
59  }
60 
62  basic_endpoint(const void* socket_address,
63  std::size_t socket_address_size, int socket_protocol = 0)
64  : impl_(socket_address, socket_address_size, socket_protocol)
65  {
66  }
67 
69  template <typename Endpoint>
70  basic_endpoint(const Endpoint& endpoint)
71  : impl_(endpoint.data(), endpoint.size(), endpoint.protocol().protocol())
72  {
73  }
74 
77  : impl_(other.impl_)
78  {
79  }
80 
81 #if defined(ASIO_HAS_MOVE)
84  : impl_(other.impl_)
85  {
86  }
87 #endif // defined(ASIO_HAS_MOVE)
88 
91  {
92  impl_ = other.impl_;
93  return *this;
94  }
95 
96 #if defined(ASIO_HAS_MOVE)
99  {
100  impl_ = other.impl_;
101  return *this;
102  }
103 #endif // defined(ASIO_HAS_MOVE)
104 
106  protocol_type protocol() const
107  {
108  return protocol_type(impl_.family(), impl_.protocol());
109  }
110 
112  data_type* data()
113  {
114  return impl_.data();
115  }
116 
118  const data_type* data() const
119  {
120  return impl_.data();
121  }
122 
124  std::size_t size() const
125  {
126  return impl_.size();
127  }
128 
130  void resize(std::size_t new_size)
131  {
132  impl_.resize(new_size);
133  }
134 
136  std::size_t capacity() const
137  {
138  return impl_.capacity();
139  }
140 
142  friend bool operator==(const basic_endpoint<Protocol>& e1,
143  const basic_endpoint<Protocol>& e2)
144  {
145  return e1.impl_ == e2.impl_;
146  }
147 
149  friend bool operator!=(const basic_endpoint<Protocol>& e1,
150  const basic_endpoint<Protocol>& e2)
151  {
152  return !(e1.impl_ == e2.impl_);
153  }
154 
156  friend bool operator<(const basic_endpoint<Protocol>& e1,
157  const basic_endpoint<Protocol>& e2)
158  {
159  return e1.impl_ < e2.impl_;
160  }
161 
163  friend bool operator>(const basic_endpoint<Protocol>& e1,
164  const basic_endpoint<Protocol>& e2)
165  {
166  return e2.impl_ < e1.impl_;
167  }
168 
170  friend bool operator<=(const basic_endpoint<Protocol>& e1,
171  const basic_endpoint<Protocol>& e2)
172  {
173  return !(e2 < e1);
174  }
175 
177  friend bool operator>=(const basic_endpoint<Protocol>& e1,
178  const basic_endpoint<Protocol>& e2)
179  {
180  return !(e1 < e2);
181  }
182 
183 private:
184  // The underlying generic endpoint.
186 };
187 
188 } // namespace generic
189 } // namespace asio
190 
192 
193 #endif // ASIO_GENERIC_BASIC_ENDPOINT_HPP
std::size_t capacity() const
Get the capacity of the endpoint in the native type.
const data_type * data() const
Get the underlying endpoint in the native type.
friend bool operator>=(const basic_endpoint< Protocol > &e1, const basic_endpoint< Protocol > &e2)
Compare endpoints for ordering.
basic_endpoint(const Endpoint &endpoint)
Construct an endpoint from the specific endpoint type.
std::size_t size() const
Definition: endpoint.hpp:82
Protocol protocol_type
The protocol type associated with the endpoint.
data_type * data()
Get the underlying endpoint in the native type.
sockaddr socket_addr_type
ASIO_DECL void resize(std::size_t size)
Definition: endpoint.ipp:45
friend bool operator>(const basic_endpoint< Protocol > &e1, const basic_endpoint< Protocol > &e2)
Compare endpoints for ordering.
basic_endpoint(const void *socket_address, std::size_t socket_address_size, int socket_protocol=0)
Construct an endpoint from the specified socket address.
protocol_type protocol() const
The protocol associated with the endpoint.
basic_endpoint()
Default constructor.
basic_endpoint & operator=(const basic_endpoint &other)
Assign from another endpoint.
asio::detail::socket_addr_type * data()
Definition: endpoint.hpp:70
std::size_t size() const
Get the underlying size of the endpoint in the native type.
void resize(std::size_t new_size)
Set the underlying size of the endpoint in the native type.
basic_endpoint(const basic_endpoint &other)
Copy constructor.
asio::detail::socket_addr_type data_type
friend bool operator==(const basic_endpoint< Protocol > &e1, const basic_endpoint< Protocol > &e2)
Compare two endpoints for equality.
friend bool operator!=(const basic_endpoint< Protocol > &e1, const basic_endpoint< Protocol > &e2)
Compare two endpoints for inequality.
std::size_t capacity() const
Definition: endpoint.hpp:91
Describes an endpoint for any socket type.