Realistic 3D camera system
3D camera system components
endpoint.hpp
Go to the documentation of this file.
1 //
2 // generic/detail/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_DETAIL_ENDPOINT_HPP
12 #define ASIO_GENERIC_DETAIL_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"
19 
20 #include <cstddef>
22 
24 
25 namespace asio {
26 namespace generic {
27 namespace detail {
28 
29 // Helper class for implementing a generic socket endpoint.
30 class endpoint
31 {
32 public:
33  // Default constructor.
35 
36  // Construct an endpoint from the specified raw bytes.
37  ASIO_DECL endpoint(const void* sock_addr,
38  std::size_t sock_addr_size, int sock_protocol);
39 
40  // Copy constructor.
41  endpoint(const endpoint& other)
42  : data_(other.data_),
43  size_(other.size_),
44  protocol_(other.protocol_)
45  {
46  }
47 
48  // Assign from another endpoint.
49  endpoint& operator=(const endpoint& other)
50  {
51  data_ = other.data_;
52  size_ = other.size_;
53  protocol_ = other.protocol_;
54  return *this;
55  }
56 
57  // Get the address family associated with the endpoint.
58  int family() const
59  {
60  return data_.base.sa_family;
61  }
62 
63  // Get the socket protocol associated with the endpoint.
64  int protocol() const
65  {
66  return protocol_;
67  }
68 
69  // Get the underlying endpoint in the native type.
71  {
72  return &data_.base;
73  }
74 
75  // Get the underlying endpoint in the native type.
77  {
78  return &data_.base;
79  }
80 
81  // Get the underlying size of the endpoint in the native type.
82  std::size_t size() const
83  {
84  return size_;
85  }
86 
87  // Set the underlying size of the endpoint in the native type.
88  ASIO_DECL void resize(std::size_t size);
89 
90  // Get the capacity of the endpoint in the native type.
91  std::size_t capacity() const
92  {
94  }
95 
96  // Compare two endpoints for equality.
97  ASIO_DECL friend bool operator==(
98  const endpoint& e1, const endpoint& e2);
99 
100  // Compare endpoints for ordering.
101  ASIO_DECL friend bool operator<(
102  const endpoint& e1, const endpoint& e2);
103 
104 private:
105  // The underlying socket address.
106  union data_union
107  {
110  } data_;
111 
112  // The length of the socket address stored in the endpoint.
113  std::size_t size_;
114 
115  // The socket protocol associated with the endpoint.
116  int protocol_;
117 
118  // Initialise with a specified memory.
119  ASIO_DECL void init(const void* sock_addr,
120  std::size_t sock_addr_size, int sock_protocol);
121 };
122 
123 } // namespace detail
124 } // namespace generic
125 } // namespace asio
126 
128 
129 #if defined(ASIO_HEADER_ONLY)
131 #endif // defined(ASIO_HEADER_ONLY)
132 
133 #endif // ASIO_GENERIC_DETAIL_ENDPOINT_HPP
endpoint(const endpoint &other)
Definition: endpoint.hpp:41
ASIO_DECL friend bool operator==(const endpoint &e1, const endpoint &e2)
Definition: endpoint.ipp:59
sockaddr_storage sockaddr_storage_type
asio::basic_streambuf< Allocator > MatchCondition enable_if< is_match_condition< MatchCondition >::value >::type *detail::async_result_init< ReadHandler, void(asio::error_code, std::size_t)> init(ASIO_MOVE_CAST(ReadHandler)(handler))
std::size_t size() const
Definition: endpoint.hpp:82
sockaddr socket_addr_type
ASIO_DECL friend bool operator<(const endpoint &e1, const endpoint &e2)
Definition: endpoint.ipp:65
ASIO_DECL void resize(std::size_t size)
Definition: endpoint.ipp:45
#define ASIO_DECL
Definition: config.hpp:43
asio::detail::socket_addr_type * data()
Definition: endpoint.hpp:70
endpoint & operator=(const endpoint &other)
Definition: endpoint.hpp:49
const asio::detail::socket_addr_type * data() const
Definition: endpoint.hpp:76
std::size_t capacity() const
Definition: endpoint.hpp:91