]> git.sesse.net Git - casparcg/blob - dependencies64/boost/boost/asio/serial_port_base.hpp
Unpacked dependencies64
[casparcg] / dependencies64 / boost / boost / asio / serial_port_base.hpp
1 //
2 // serial_port_base.hpp
3 // ~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
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 BOOST_ASIO_SERIAL_PORT_BASE_HPP
13 #define BOOST_ASIO_SERIAL_PORT_BASE_HPP
14
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
19 #include <boost/asio/detail/config.hpp>
20
21 #if defined(BOOST_ASIO_HAS_SERIAL_PORT) \
22   || defined(GENERATING_DOCUMENTATION)
23
24 #if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
25 # include <termios.h>
26 #endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
27
28 #include <boost/detail/workaround.hpp>
29 #include <boost/asio/detail/socket_types.hpp>
30 #include <boost/system/error_code.hpp>
31
32 #if defined(GENERATING_DOCUMENTATION)
33 # define BOOST_ASIO_OPTION_STORAGE implementation_defined
34 #elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
35 # define BOOST_ASIO_OPTION_STORAGE DCB
36 #else
37 # define BOOST_ASIO_OPTION_STORAGE termios
38 #endif
39
40 #include <boost/asio/detail/push_options.hpp>
41
42 namespace boost {
43 namespace asio {
44
45 /// The serial_port_base class is used as a base for the basic_serial_port class
46 /// template so that we have a common place to define the serial port options.
47 class serial_port_base
48 {
49 public:
50   /// Serial port option to permit changing the baud rate.
51   /**
52    * Implements changing the baud rate for a given serial port.
53    */
54   class baud_rate
55   {
56   public:
57     explicit baud_rate(unsigned int rate = 0);
58     unsigned int value() const;
59     BOOST_ASIO_DECL boost::system::error_code store(
60         BOOST_ASIO_OPTION_STORAGE& storage,
61         boost::system::error_code& ec) const;
62     BOOST_ASIO_DECL boost::system::error_code load(
63         const BOOST_ASIO_OPTION_STORAGE& storage,
64         boost::system::error_code& ec);
65   private:
66     unsigned int value_;
67   };
68
69   /// Serial port option to permit changing the flow control.
70   /**
71    * Implements changing the flow control for a given serial port.
72    */
73   class flow_control
74   {
75   public:
76     enum type { none, software, hardware };
77     BOOST_ASIO_DECL explicit flow_control(type t = none);
78     type value() const;
79     BOOST_ASIO_DECL boost::system::error_code store(
80         BOOST_ASIO_OPTION_STORAGE& storage,
81         boost::system::error_code& ec) const;
82     BOOST_ASIO_DECL boost::system::error_code load(
83         const BOOST_ASIO_OPTION_STORAGE& storage,
84         boost::system::error_code& ec);
85   private:
86     type value_;
87   };
88
89   /// Serial port option to permit changing the parity.
90   /**
91    * Implements changing the parity for a given serial port.
92    */
93   class parity
94   {
95   public:
96     enum type { none, odd, even };
97     BOOST_ASIO_DECL explicit parity(type t = none);
98     type value() const;
99     BOOST_ASIO_DECL boost::system::error_code store(
100         BOOST_ASIO_OPTION_STORAGE& storage,
101         boost::system::error_code& ec) const;
102     BOOST_ASIO_DECL boost::system::error_code load(
103         const BOOST_ASIO_OPTION_STORAGE& storage,
104         boost::system::error_code& ec);
105   private:
106     type value_;
107   };
108
109   /// Serial port option to permit changing the number of stop bits.
110   /**
111    * Implements changing the number of stop bits for a given serial port.
112    */
113   class stop_bits
114   {
115   public:
116     enum type { one, onepointfive, two };
117     BOOST_ASIO_DECL explicit stop_bits(type t = one);
118     type value() const;
119     BOOST_ASIO_DECL boost::system::error_code store(
120         BOOST_ASIO_OPTION_STORAGE& storage,
121         boost::system::error_code& ec) const;
122     BOOST_ASIO_DECL boost::system::error_code load(
123         const BOOST_ASIO_OPTION_STORAGE& storage,
124         boost::system::error_code& ec);
125   private:
126     type value_;
127   };
128
129   /// Serial port option to permit changing the character size.
130   /**
131    * Implements changing the character size for a given serial port.
132    */
133   class character_size
134   {
135   public:
136     BOOST_ASIO_DECL explicit character_size(unsigned int t = 8);
137     unsigned int value() const;
138     BOOST_ASIO_DECL boost::system::error_code store(
139         BOOST_ASIO_OPTION_STORAGE& storage,
140         boost::system::error_code& ec) const;
141     BOOST_ASIO_DECL boost::system::error_code load(
142         const BOOST_ASIO_OPTION_STORAGE& storage,
143         boost::system::error_code& ec);
144   private:
145     unsigned int value_;
146   };
147
148 protected:
149   /// Protected destructor to prevent deletion through this type.
150   ~serial_port_base()
151   {
152   }
153
154 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
155 private:
156   // Workaround to enable the empty base optimisation with Borland C++.
157   char dummy_;
158 #endif
159 };
160
161 } // namespace asio
162 } // namespace boost
163
164 #include <boost/asio/detail/pop_options.hpp>
165
166 #undef BOOST_ASIO_OPTION_STORAGE
167
168 #include <boost/asio/impl/serial_port_base.hpp>
169 #if defined(BOOST_ASIO_HEADER_ONLY)
170 # include <boost/asio/impl/serial_port_base.ipp>
171 #endif // defined(BOOST_ASIO_HEADER_ONLY)
172
173 #endif // defined(BOOST_ASIO_HAS_SERIAL_PORT)
174        //   || defined(GENERATING_DOCUMENTATION)
175
176 #endif // BOOST_ASIO_SERIAL_PORT_BASE_HPP