~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/asio/serial_port_base.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// serial_port_base.hpp
3
 
// ~~~~~~~~~~~~~~~~~~~~
4
 
//
5
 
// Copyright (c) 2003-2008 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 ASIO_SERIAL_PORT_BASE_HPP
13
 
#define 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 "asio/detail/push_options.hpp"
20
 
 
21
 
#include "asio/detail/push_options.hpp"
22
 
#include <stdexcept>
23
 
#include <boost/config.hpp>
24
 
#include <boost/detail/workaround.hpp>
25
 
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
26
 
# include <termios.h>
27
 
#endif
28
 
#include "asio/detail/pop_options.hpp"
29
 
 
30
 
#include "asio/error_code.hpp"
31
 
#include "asio/detail/socket_types.hpp"
32
 
 
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
37
 
#else
38
 
# define ASIO_OPTION_STORAGE termios
39
 
#endif
40
 
 
41
 
namespace asio {
42
 
 
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
46
 
{
47
 
public:
48
 
  /// Serial port option to permit changing the baud rate.
49
 
  /**
50
 
   * Implements changing the baud rate for a given serial port.
51
 
   */
52
 
  class baud_rate
53
 
  {
54
 
  public:
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);
61
 
  private:
62
 
    unsigned int value_;
63
 
  };
64
 
 
65
 
  /// Serial port option to permit changing the flow control.
66
 
  /**
67
 
   * Implements changing the flow control for a given serial port.
68
 
   */
69
 
  class flow_control
70
 
  {
71
 
  public:
72
 
    enum type { none, software, hardware };
73
 
    explicit flow_control(type t = none);
74
 
    type value() const;
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);
79
 
  private:
80
 
    type value_;
81
 
  };
82
 
 
83
 
  /// Serial port option to permit changing the parity.
84
 
  /**
85
 
   * Implements changing the parity for a given serial port.
86
 
   */
87
 
  class parity
88
 
  {
89
 
  public:
90
 
    enum type { none, odd, even };
91
 
    explicit parity(type t = none);
92
 
    type value() const;
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);
97
 
  private:
98
 
    type value_;
99
 
  };
100
 
 
101
 
  /// Serial port option to permit changing the number of stop bits.
102
 
  /**
103
 
   * Implements changing the number of stop bits for a given serial port.
104
 
   */
105
 
  class stop_bits
106
 
  {
107
 
  public:
108
 
    enum type { one, onepointfive, two };
109
 
    explicit stop_bits(type t = one);
110
 
    type value() const;
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);
115
 
  private:
116
 
    type value_;
117
 
  };
118
 
 
119
 
  /// Serial port option to permit changing the character size.
120
 
  /**
121
 
   * Implements changing the character size for a given serial port.
122
 
   */
123
 
  class character_size
124
 
  {
125
 
  public:
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);
132
 
  private:
133
 
    unsigned int value_;
134
 
  };
135
 
 
136
 
protected:
137
 
  /// Protected destructor to prevent deletion through this type.
138
 
  ~serial_port_base()
139
 
  {
140
 
  }
141
 
 
142
 
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
143
 
private:
144
 
  // Workaround to enable the empty base optimisation with Borland C++.
145
 
  char dummy_;
146
 
#endif
147
 
};
148
 
 
149
 
} // namespace asio
150
 
 
151
 
#include "asio/impl/serial_port_base.ipp"
152
 
 
153
 
#undef ASIO_OPTION_STORAGE
154
 
 
155
 
#include "asio/detail/pop_options.hpp"
156
 
 
157
 
#endif // ASIO_SERIAL_PORT_BASE_HPP