modm API documentation
modm/src/modm/io/iodevice.hpp
1 /*
2  * Copyright (c) 2009-2010, Fabian Greif
3  * Copyright (c) 2009-2010, Martin Rosekeit
4  * Copyright (c) 2012, 2014, Niklas Hauser
5  *
6  * This file is part of the modm project.
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11  */
12 // ----------------------------------------------------------------------------
13 
14 #ifndef MODM_IODEVICE_HPP
15 #define MODM_IODEVICE_HPP
16 
17 namespace modm
18 {
19 
20 /**
21  * Abstract calls of IO devices
22  *
23  * @ingroup modm_io
24  * @author Martin Rosekeit <martin.rosekeit@rwth-aachen.de>
25  */
26 class IODevice
27 {
28 public:
29  virtual
30  ~IODevice() = default;
31 
32  /// Write a single character
33  virtual void
34  write(char c) = 0;
35 
36  /// Write a C-string
37  virtual inline void
38  write(const char* str)
39  {
40  char c;
41  while ( (c = *str++) ) write(c);
42  }
43 
44  virtual void
45  flush() = 0;
46 
47  /// Read a single character
48  virtual bool
49  read(char& c) = 0;
50 };
51 
52 } // namespace modm
53 
54 #endif // MODM_IODEVICE_HPP
virtual bool read(char &c) = 0
Read a single character.
virtual void write(const char *str)
Write a C-string.
Definition: modm/src/modm/io/iodevice.hpp:38
virtual void write(char c) = 0
Write a single character.
Definition: modm/src/modm/io/iodevice.hpp:26