]> git.tdb.fi Git - libs/core.git/blob - source/io/serial.h
Use the new Handle class to hide platform details from public headers
[libs/core.git] / source / io / serial.h
1 #ifndef MSP_IO_SERIAL_H_
2 #define MSP_IO_SERIAL_H_
3
4 #include "base.h"
5 #include "handle.h"
6
7 namespace Msp {
8 namespace IO {
9
10 class Serial: public Base
11 {
12 public:
13         enum Parity
14         {
15                 NONE,
16                 EVEN,
17                 ODD
18         };
19
20 private:
21         Handle handle;
22
23 public:
24         Serial(const std::string &);
25         virtual ~Serial();
26
27 private:
28         void close();
29
30 public:
31         virtual void set_block(bool);
32
33         void set_baud_rate(unsigned);
34         void set_data_bits(unsigned);
35         void set_parity(Parity);
36         void set_stop_bits(unsigned);
37         void set_parameters(const std::string &);
38
39 private:
40         virtual unsigned do_write(const char *, unsigned);
41         virtual unsigned do_read(char *, unsigned);
42
43 public:
44         virtual const Handle &get_event_handle();
45 };
46
47 } // namespace IO
48 } // namespace Msp
49
50 #endif