Realistic 3D camera system
3D camera system components
seq_packet_protocol.hpp
Go to the documentation of this file.
1 //
2 // generic/seq_packet_protocol.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_SEQ_PACKET_PROTOCOL_HPP
12 #define ASIO_GENERIC_SEQ_PACKET_PROTOCOL_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 <typeinfo>
25 
27 
28 namespace asio {
29 namespace generic {
30 
32 
48 {
49 public:
51  seq_packet_protocol(int address_family, int socket_protocol)
52  : family_(address_family),
53  protocol_(socket_protocol)
54  {
55  }
56 
58 
62  template <typename Protocol>
63  seq_packet_protocol(const Protocol& source_protocol)
64  : family_(source_protocol.family()),
65  protocol_(source_protocol.protocol())
66  {
67  if (source_protocol.type() != type())
68  {
69  std::bad_cast ex;
71  }
72  }
73 
75  int type() const
76  {
77  return ASIO_OS_DEF(SOCK_SEQPACKET);
78  }
79 
81  int protocol() const
82  {
83  return protocol_;
84  }
85 
87  int family() const
88  {
89  return family_;
90  }
91 
93  friend bool operator==(const seq_packet_protocol& p1,
94  const seq_packet_protocol& p2)
95  {
96  return p1.family_ == p2.family_ && p1.protocol_ == p2.protocol_;
97  }
98 
100  friend bool operator!=(const seq_packet_protocol& p1,
101  const seq_packet_protocol& p2)
102  {
103  return !(p1 == p2);
104  }
105 
108 
111 
112 private:
113  int family_;
114  int protocol_;
115 };
116 
117 } // namespace generic
118 } // namespace asio
119 
121 
122 #endif // ASIO_GENERIC_SEQ_PACKET_PROTOCOL_HPP
int protocol() const
Obtain an identifier for the protocol.
int type() const
Obtain an identifier for the type of the protocol.
#define ASIO_OS_DEF(c)
basic_seq_packet_socket< seq_packet_protocol > socket
The generic socket type.
Encapsulates the flags needed for a generic sequenced packet socket.
int family() const
Obtain an identifier for the protocol family.
friend bool operator==(const seq_packet_protocol &p1, const seq_packet_protocol &p2)
Compare two protocols for equality.
seq_packet_protocol(int address_family, int socket_protocol)
Construct a protocol object for a specific address family and protocol.
Provides sequenced packet socket functionality.
seq_packet_protocol(const Protocol &source_protocol)
Construct a generic protocol object from a specific protocol.
basic_endpoint< seq_packet_protocol > endpoint
The type of an endpoint.
void throw_exception(const Exception &e)
friend bool operator!=(const seq_packet_protocol &p1, const seq_packet_protocol &p2)
Compare two protocols for inequality.
Describes an endpoint for any socket type.