Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
4.4KB

  1. //
  2. // serial_port_base.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 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. #ifndef ASIO_SERIAL_PORT_BASE_HPP
  12. #define ASIO_SERIAL_PORT_BASE_HPP
  13. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  14. # pragma once
  15. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  16. #include "asio/detail/config.hpp"
  17. #if defined(ASIO_HAS_SERIAL_PORT) \
  18. || defined(GENERATING_DOCUMENTATION)
  19. #if !defined(ASIO_WINDOWS) && !defined(__CYGWIN__)
  20. # include <termios.h>
  21. #endif // !defined(ASIO_WINDOWS) && !defined(__CYGWIN__)
  22. #include "asio/detail/socket_types.hpp"
  23. #include "asio/error_code.hpp"
  24. #if defined(GENERATING_DOCUMENTATION)
  25. # define ASIO_OPTION_STORAGE implementation_defined
  26. #elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  27. # define ASIO_OPTION_STORAGE DCB
  28. #else
  29. # define ASIO_OPTION_STORAGE termios
  30. #endif
  31. #include "asio/detail/push_options.hpp"
  32. namespace asio {
  33. /// The serial_port_base class is used as a base for the basic_serial_port class
  34. /// template so that we have a common place to define the serial port options.
  35. class serial_port_base
  36. {
  37. public:
  38. /// Serial port option to permit changing the baud rate.
  39. /**
  40. * Implements changing the baud rate for a given serial port.
  41. */
  42. class baud_rate
  43. {
  44. public:
  45. explicit baud_rate(unsigned int rate = 0);
  46. unsigned int value() const;
  47. ASIO_DECL asio::error_code store(
  48. ASIO_OPTION_STORAGE& storage,
  49. asio::error_code& ec) const;
  50. ASIO_DECL asio::error_code load(
  51. const ASIO_OPTION_STORAGE& storage,
  52. asio::error_code& ec);
  53. private:
  54. unsigned int value_;
  55. };
  56. /// Serial port option to permit changing the flow control.
  57. /**
  58. * Implements changing the flow control for a given serial port.
  59. */
  60. class flow_control
  61. {
  62. public:
  63. enum type { none, software, hardware };
  64. ASIO_DECL explicit flow_control(type t = none);
  65. type value() const;
  66. ASIO_DECL asio::error_code store(
  67. ASIO_OPTION_STORAGE& storage,
  68. asio::error_code& ec) const;
  69. ASIO_DECL asio::error_code load(
  70. const ASIO_OPTION_STORAGE& storage,
  71. asio::error_code& ec);
  72. private:
  73. type value_;
  74. };
  75. /// Serial port option to permit changing the parity.
  76. /**
  77. * Implements changing the parity for a given serial port.
  78. */
  79. class parity
  80. {
  81. public:
  82. enum type { none, odd, even };
  83. ASIO_DECL explicit parity(type t = none);
  84. type value() const;
  85. ASIO_DECL asio::error_code store(
  86. ASIO_OPTION_STORAGE& storage,
  87. asio::error_code& ec) const;
  88. ASIO_DECL asio::error_code load(
  89. const ASIO_OPTION_STORAGE& storage,
  90. asio::error_code& ec);
  91. private:
  92. type value_;
  93. };
  94. /// Serial port option to permit changing the number of stop bits.
  95. /**
  96. * Implements changing the number of stop bits for a given serial port.
  97. */
  98. class stop_bits
  99. {
  100. public:
  101. enum type { one, onepointfive, two };
  102. ASIO_DECL explicit stop_bits(type t = one);
  103. type value() const;
  104. ASIO_DECL asio::error_code store(
  105. ASIO_OPTION_STORAGE& storage,
  106. asio::error_code& ec) const;
  107. ASIO_DECL asio::error_code load(
  108. const ASIO_OPTION_STORAGE& storage,
  109. asio::error_code& ec);
  110. private:
  111. type value_;
  112. };
  113. /// Serial port option to permit changing the character size.
  114. /**
  115. * Implements changing the character size for a given serial port.
  116. */
  117. class character_size
  118. {
  119. public:
  120. ASIO_DECL explicit character_size(unsigned int t = 8);
  121. unsigned int value() const;
  122. ASIO_DECL asio::error_code store(
  123. ASIO_OPTION_STORAGE& storage,
  124. asio::error_code& ec) const;
  125. ASIO_DECL asio::error_code load(
  126. const ASIO_OPTION_STORAGE& storage,
  127. asio::error_code& ec);
  128. private:
  129. unsigned int value_;
  130. };
  131. protected:
  132. /// Protected destructor to prevent deletion through this type.
  133. ~serial_port_base()
  134. {
  135. }
  136. };
  137. } // namespace asio
  138. #include "asio/detail/pop_options.hpp"
  139. #undef ASIO_OPTION_STORAGE
  140. #include "asio/impl/serial_port_base.hpp"
  141. #if defined(ASIO_HEADER_ONLY)
  142. # include "asio/impl/serial_port_base.ipp"
  143. #endif // defined(ASIO_HEADER_ONLY)
  144. #endif // defined(ASIO_HAS_SERIAL_PORT)
  145. // || defined(GENERATING_DOCUMENTATION)
  146. #endif // ASIO_SERIAL_PORT_BASE_HPP