libcsdbg  1.28
C++ exception (and generic) stack trace debug library
sttybuf.hpp
Go to the documentation of this file.
1 #ifndef _CSDBG_STTYBUF
2 #define _CSDBG_STTYBUF 1
3 
10 #include "./streambuf.hpp"
11 
12 namespace csdbg {
13 
28 class sttybuf: virtual public streambuf
29 {
30 protected:
31 
32  /* Protected variables */
33 
39  /* Protected generic methods */
40 
41  virtual sttybuf& config() const;
42 
43 public:
44 
45  /* Constructors, copy constructors and destructor */
46 
47  sttybuf(const i8*, u32 = 9600);
48 
49  sttybuf(const sttybuf&);
50 
51  virtual ~sttybuf();
52 
53  virtual sttybuf* clone() const;
54 
55 
56  /* Accessor methods */
57 
58  virtual const i8* devnode() const;
59 
60  virtual u32 baud() const;
61 
62  virtual sttybuf& set_baud(u32);
63 
64 
65  /* Operator overloading methods */
66 
67  virtual sttybuf& operator=(const sttybuf&);
68 
69 
70  /* Generic methods */
71 
72  virtual bool is_tty() const;
73 
74  virtual sttybuf& open();
75 
76  virtual sttybuf& open(bool);
77 
78  virtual sttybuf& flush();
79 
80  virtual sttybuf& sync() const;
81 
82  virtual sttybuf& discard() const;
83 
84  static u32 translate_baud(u32);
85 };
86 
87 }
88 
89 #endif
90 
u32 m_baud
Baud rate.
Definition: sttybuf.hpp:36
sttybuf(const i8 *, u32=9600)
Object constructor.
Definition: sttybuf.cpp:67
A buffered output stream for serial interfaces.
Definition: sttybuf.hpp:28
static u32 translate_baud(u32)
Translate a number to a baud rate as defined in termios.h.
Definition: sttybuf.cpp:390
virtual sttybuf & sync() const
Commit cached data to the serial interface line.
Definition: sttybuf.cpp:330
This abstract class is the base for all buffered output stream types (for files, sockets, serial interfaces e.t.c)
Definition: streambuf.hpp:37
char i8
8-bit signed integer
Definition: config.hpp:72
Class csdbg::streambuf definition.
virtual const i8 * devnode() const
Get the path of the serial interface device node.
Definition: sttybuf.cpp:143
virtual sttybuf * clone() const
Object virtual copy constructor.
Definition: sttybuf.cpp:132
virtual sttybuf & open()
Open the serial interface for output.
Definition: sttybuf.cpp:233
virtual sttybuf & flush()
Flush the buffered data to the serial interface.
Definition: sttybuf.cpp:304
virtual ~sttybuf()
Object destructor.
Definition: sttybuf.cpp:117
virtual sttybuf & discard() const
Discard the data cached in the serial interface (in-kernel) buffers.
Definition: sttybuf.cpp:355
i8 * m_devnode
Device node file (devfs)
Definition: sttybuf.hpp:34
virtual sttybuf & set_baud(u32)
Set the baud rate.
Definition: sttybuf.cpp:169
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
virtual sttybuf & config() const
Configure the serial interface.
Definition: sttybuf.cpp:22
virtual u32 baud() const
Get the baud rate.
Definition: sttybuf.cpp:154
virtual bool is_tty() const
Check if the device node is a terminal.
Definition: sttybuf.cpp:217
virtual sttybuf & operator=(const sttybuf &)
Assignment operator.
Definition: sttybuf.cpp:192