Realistic 3D camera system
3D camera system components
endpoint.hpp
Go to the documentation of this file.
1 //
2 // local/detail/endpoint.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Derived from a public domain implementation written by Daniel Casimiro.
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 //
11 
12 #ifndef ASIO_LOCAL_DETAIL_ENDPOINT_HPP
13 #define ASIO_LOCAL_DETAIL_ENDPOINT_HPP
14 
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 
19 #include "asio/detail/config.hpp"
20 
21 #if defined(ASIO_HAS_LOCAL_SOCKETS)
22 
23 #include <cstddef>
24 #include <string>
26 
28 
29 namespace asio {
30 namespace local {
31 namespace detail {
32 
33 // Helper class for implementing a UNIX domain endpoint.
34 class endpoint
35 {
36 public:
37  // Default constructor.
38  ASIO_DECL endpoint();
39 
40  // Construct an endpoint using the specified path name.
41  ASIO_DECL endpoint(const char* path_name);
42 
43  // Construct an endpoint using the specified path name.
44  ASIO_DECL endpoint(const std::string& path_name);
45 
46  // Copy constructor.
47  endpoint(const endpoint& other)
48  : data_(other.data_),
49  path_length_(other.path_length_)
50  {
51  }
52 
53  // Assign from another endpoint.
54  endpoint& operator=(const endpoint& other)
55  {
56  data_ = other.data_;
57  path_length_ = other.path_length_;
58  return *this;
59  }
60 
61  // Get the underlying endpoint in the native type.
63  {
64  return &data_.base;
65  }
66 
67  // Get the underlying endpoint in the native type.
68  const asio::detail::socket_addr_type* data() const
69  {
70  return &data_.base;
71  }
72 
73  // Get the underlying size of the endpoint in the native type.
74  std::size_t size() const
75  {
76  return path_length_
77  + offsetof(asio::detail::sockaddr_un_type, sun_path);
78  }
79 
80  // Set the underlying size of the endpoint in the native type.
81  ASIO_DECL void resize(std::size_t size);
82 
83  // Get the capacity of the endpoint in the native type.
84  std::size_t capacity() const
85  {
86  return sizeof(asio::detail::sockaddr_un_type);
87  }
88 
89  // Get the path associated with the endpoint.
90  ASIO_DECL std::string path() const;
91 
92  // Set the path associated with the endpoint.
93  ASIO_DECL void path(const char* p);
94 
95  // Set the path associated with the endpoint.
96  ASIO_DECL void path(const std::string& p);
97 
98  // Compare two endpoints for equality.
99  ASIO_DECL friend bool operator==(
100  const endpoint& e1, const endpoint& e2);
101 
102  // Compare endpoints for ordering.
103  ASIO_DECL friend bool operator<(
104  const endpoint& e1, const endpoint& e2);
105 
106 private:
107  // The underlying UNIX socket address.
108  union data_union
109  {
112  } data_;
113 
114  // The length of the path associated with the endpoint.
115  std::size_t path_length_;
116 
117  // Initialise with a specified path.
118  ASIO_DECL void init(const char* path, std::size_t path_length);
119 };
120 
121 } // namespace detail
122 } // namespace local
123 } // namespace asio
124 
126 
127 #if defined(ASIO_HEADER_ONLY)
129 #endif // defined(ASIO_HEADER_ONLY)
130 
131 #endif // defined(ASIO_HAS_LOCAL_SOCKETS)
132 
133 #endif // ASIO_LOCAL_DETAIL_ENDPOINT_HPP
sockaddr_un sockaddr_un_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))
bool operator<(const endpoint &e1, const endpoint &e2)
Definition: endpoint.ipp:65
sockaddr socket_addr_type
bool operator==(const endpoint &e1, const endpoint &e2)
Definition: endpoint.ipp:59
#define ASIO_DECL
Definition: config.hpp:43