2
// serial_port_base.hpp
3
// ~~~~~~~~~~~~~~~~~~~~
5
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6
// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
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)
12
#ifndef ASIO_SERIAL_PORT_BASE_HPP
13
#define ASIO_SERIAL_PORT_BASE_HPP
15
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
17
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
19
#include "asio/detail/push_options.hpp"
21
#include "asio/detail/push_options.hpp"
23
#include <boost/config.hpp>
24
#include <boost/detail/workaround.hpp>
25
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
28
#include "asio/detail/pop_options.hpp"
30
#include "asio/error_code.hpp"
31
#include "asio/detail/socket_types.hpp"
33
#if defined(GENERATING_DOCUMENTATION)
34
# define ASIO_OPTION_STORAGE implementation_defined
35
#elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
36
# define ASIO_OPTION_STORAGE DCB
38
# define ASIO_OPTION_STORAGE termios
43
/// The serial_port_base class is used as a base for the basic_serial_port class
44
/// template so that we have a common place to define the serial port options.
45
class serial_port_base
48
/// Serial port option to permit changing the baud rate.
50
* Implements changing the baud rate for a given serial port.
55
explicit baud_rate(unsigned int rate = 0);
56
unsigned int value() const;
57
asio::error_code store(ASIO_OPTION_STORAGE& storage,
58
asio::error_code& ec) const;
59
asio::error_code load(const ASIO_OPTION_STORAGE& storage,
60
asio::error_code& ec);
65
/// Serial port option to permit changing the flow control.
67
* Implements changing the flow control for a given serial port.
72
enum type { none, software, hardware };
73
explicit flow_control(type t = none);
75
asio::error_code store(ASIO_OPTION_STORAGE& storage,
76
asio::error_code& ec) const;
77
asio::error_code load(const ASIO_OPTION_STORAGE& storage,
78
asio::error_code& ec);
83
/// Serial port option to permit changing the parity.
85
* Implements changing the parity for a given serial port.
90
enum type { none, odd, even };
91
explicit parity(type t = none);
93
asio::error_code store(ASIO_OPTION_STORAGE& storage,
94
asio::error_code& ec) const;
95
asio::error_code load(const ASIO_OPTION_STORAGE& storage,
96
asio::error_code& ec);
101
/// Serial port option to permit changing the number of stop bits.
103
* Implements changing the number of stop bits for a given serial port.
108
enum type { one, onepointfive, two };
109
explicit stop_bits(type t = one);
111
asio::error_code store(ASIO_OPTION_STORAGE& storage,
112
asio::error_code& ec) const;
113
asio::error_code load(const ASIO_OPTION_STORAGE& storage,
114
asio::error_code& ec);
119
/// Serial port option to permit changing the character size.
121
* Implements changing the character size for a given serial port.
126
explicit character_size(unsigned int t = 8);
127
unsigned int value() const;
128
asio::error_code store(ASIO_OPTION_STORAGE& storage,
129
asio::error_code& ec) const;
130
asio::error_code load(const ASIO_OPTION_STORAGE& storage,
131
asio::error_code& ec);
137
/// Protected destructor to prevent deletion through this type.
142
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
144
// Workaround to enable the empty base optimisation with Borland C++.
151
#include "asio/impl/serial_port_base.ipp"
153
#undef ASIO_OPTION_STORAGE
155
#include "asio/detail/pop_options.hpp"
157
#endif // ASIO_SERIAL_PORT_BASE_HPP