Realistic 3D camera system
3D camera system components
raw_protocol.hpp
Go to the documentation of this file.
1 //
2 // generic/raw_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_RAW_PROTOCOL_HPP
12 #define ASIO_GENERIC_RAW_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 
50 {
51 public:
53  raw_protocol(int address_family, int socket_protocol)
54  : family_(address_family),
55  protocol_(socket_protocol)
56  {
57  }
58 
60 
63  template <typename Protocol>
64  raw_protocol(const Protocol& source_protocol)
65  : family_(source_protocol.family()),
66  protocol_(source_protocol.protocol())
67  {
68  if (source_protocol.type() != type())
69  {
70  std::bad_cast ex;
72  }
73  }
74 
76  int type() const
77  {
78  return ASIO_OS_DEF(SOCK_RAW);
79  }
80 
82  int protocol() const
83  {
84  return protocol_;
85  }
86 
88  int family() const
89  {
90  return family_;
91  }
92 
94  friend bool operator==(const raw_protocol& p1, const raw_protocol& p2)
95  {
96  return p1.family_ == p2.family_ && p1.protocol_ == p2.protocol_;
97  }
98 
100  friend bool operator!=(const raw_protocol& p1, const raw_protocol& p2)
101  {
102  return !(p1 == p2);
103  }
104 
107 
110 
111 private:
112  int family_;
113  int protocol_;
114 };
115 
116 } // namespace generic
117 } // namespace asio
118 
120 
121 #endif // ASIO_GENERIC_RAW_PROTOCOL_HPP
#define ASIO_OS_DEF(c)
basic_raw_socket< raw_protocol > socket
The generic socket type.
raw_protocol(const Protocol &source_protocol)
Construct a generic protocol object from a specific protocol.
int protocol() const
Obtain an identifier for the protocol.
Provides raw-oriented socket functionality.
raw_protocol(int address_family, int socket_protocol)
Construct a protocol object for a specific address family and protocol.
int type() const
Obtain an identifier for the type of the protocol.
basic_endpoint< raw_protocol > endpoint
The type of an endpoint.
void throw_exception(const Exception &e)
int family() const
Obtain an identifier for the protocol family.
friend bool operator==(const raw_protocol &p1, const raw_protocol &p2)
Compare two protocols for equality.
Encapsulates the flags needed for a generic raw socket.
Describes an endpoint for any socket type.
friend bool operator!=(const raw_protocol &p1, const raw_protocol &p2)
Compare two protocols for inequality.