$search
00001 // 00002 // serial_port_base.hpp 00003 // ~~~~~~~~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) 00006 // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) 00007 // 00008 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00010 // 00011 00012 #ifndef ASIO_SERIAL_PORT_BASE_HPP 00013 #define ASIO_SERIAL_PORT_BASE_HPP 00014 00015 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 00016 # pragma once 00017 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 00018 00019 #include "asio/detail/push_options.hpp" 00020 00021 #include "asio/detail/push_options.hpp" 00022 #include <stdexcept> 00023 #include <boost/config.hpp> 00024 #include <boost/detail/workaround.hpp> 00025 #if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) 00026 # include <termios.h> 00027 #endif 00028 #include "asio/detail/pop_options.hpp" 00029 00030 #include "asio/error_code.hpp" 00031 #include "asio/detail/socket_types.hpp" 00032 00033 #if defined(GENERATING_DOCUMENTATION) 00034 # define ASIO_OPTION_STORAGE implementation_defined 00035 #elif defined(BOOST_WINDOWS) || defined(__CYGWIN__) 00036 # define ASIO_OPTION_STORAGE DCB 00037 #else 00038 # define ASIO_OPTION_STORAGE termios 00039 #endif 00040 00041 namespace asio { 00042 00045 class serial_port_base 00046 { 00047 public: 00049 00052 class baud_rate 00053 { 00054 public: 00055 explicit baud_rate(unsigned int rate = 0); 00056 unsigned int value() const; 00057 asio::error_code store(ASIO_OPTION_STORAGE& storage, 00058 asio::error_code& ec) const; 00059 asio::error_code load(const ASIO_OPTION_STORAGE& storage, 00060 asio::error_code& ec); 00061 private: 00062 unsigned int value_; 00063 }; 00064 00066 00069 class flow_control 00070 { 00071 public: 00072 enum type { none, software, hardware }; 00073 explicit flow_control(type t = none); 00074 type value() const; 00075 asio::error_code store(ASIO_OPTION_STORAGE& storage, 00076 asio::error_code& ec) const; 00077 asio::error_code load(const ASIO_OPTION_STORAGE& storage, 00078 asio::error_code& ec); 00079 private: 00080 type value_; 00081 }; 00082 00084 00087 class parity 00088 { 00089 public: 00090 enum type { none, odd, even }; 00091 explicit parity(type t = none); 00092 type value() const; 00093 asio::error_code store(ASIO_OPTION_STORAGE& storage, 00094 asio::error_code& ec) const; 00095 asio::error_code load(const ASIO_OPTION_STORAGE& storage, 00096 asio::error_code& ec); 00097 private: 00098 type value_; 00099 }; 00100 00102 00105 class stop_bits 00106 { 00107 public: 00108 enum type { one, onepointfive, two }; 00109 explicit stop_bits(type t = one); 00110 type value() const; 00111 asio::error_code store(ASIO_OPTION_STORAGE& storage, 00112 asio::error_code& ec) const; 00113 asio::error_code load(const ASIO_OPTION_STORAGE& storage, 00114 asio::error_code& ec); 00115 private: 00116 type value_; 00117 }; 00118 00120 00123 class character_size 00124 { 00125 public: 00126 explicit character_size(unsigned int t = 8); 00127 unsigned int value() const; 00128 asio::error_code store(ASIO_OPTION_STORAGE& storage, 00129 asio::error_code& ec) const; 00130 asio::error_code load(const ASIO_OPTION_STORAGE& storage, 00131 asio::error_code& ec); 00132 private: 00133 unsigned int value_; 00134 }; 00135 00136 protected: 00138 ~serial_port_base() 00139 { 00140 } 00141 00142 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) 00143 private: 00144 // Workaround to enable the empty base optimisation with Borland C++. 00145 char dummy_; 00146 #endif 00147 }; 00148 00149 } // namespace asio 00150 00151 #include "asio/impl/serial_port_base.ipp" 00152 00153 #undef ASIO_OPTION_STORAGE 00154 00155 #include "asio/detail/pop_options.hpp" 00156 00157 #endif // ASIO_SERIAL_PORT_BASE_HPP