modm API documentation
style_wrapper.hpp
1 /*
2  * Copyright (c) 2009, Martin Rosekeit
3  * Copyright (c) 2009-2011, Fabian Greif
4  * Copyright (c) 2010, Georgi Grinshpun
5  * Copyright (c) 2012, Niklas Hauser
6  *
7  * This file is part of the modm project.
8  *
9  * This Source Code Form is subject to the terms of the Mozilla Public
10  * License, v. 2.0. If a copy of the MPL was not distributed with this
11  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12  */
13 // ----------------------------------------------------------------------------
14 
15 #ifndef MODM_LOG_STYLE_WRAPPER_HPP
16 #define MODM_LOG_STYLE_WRAPPER_HPP
17 
18 #include <modm/io/iodevice.hpp>
19 #include "style.hpp"
20 
21 namespace modm
22 {
23  namespace log
24  {
25  /**
26  * \brief Wrapper to use the Style as a IODevice in the Logger
27  *
28  * \ingroup modm_debug
29  * \author Martin Rosekeit <martin.rosekeit@rwth-aachen.de>
30  */
31  template < typename STYLE >
32  class StyleWrapper : public IODevice
33  {
34  public :
35  StyleWrapper( STYLE inStyle );
36 
37  virtual
38  ~StyleWrapper();
39 
40  virtual void
41  write(char c);
42 
43  virtual void
44  write(const char* str);
45 
46  virtual void
47  flush();
48 
49  virtual bool
50  read(char&);
51 
52  private :
53  StyleWrapper( const StyleWrapper& );
54 
56  operator=( const StyleWrapper& );
57 
58  STYLE style;
59  };
60  }
61 }
62 
63 // -----------------------------------------------------------------------------
64 
65 template < typename STYLE >
67  style( inStyle )
68 {
69 }
70 
71 // -----------------------------------------------------------------------------
72 
73 template < typename STYLE >
75 {
76 }
77 
78 // -----------------------------------------------------------------------------
79 
80 template < typename STYLE >
81 void
83 {
84  this->style.write( c );
85 }
86 
87 // -----------------------------------------------------------------------------
88 
89 template < typename STYLE >
90 void
92 {
93  this->style.write( s );
94 }
95 
96 // -----------------------------------------------------------------------------
97 
98 template < typename STYLE >
99 void
101 {
102  this->style.flush( );
103 }
104 
105 // -----------------------------------------------------------------------------
106 
107 template < typename STYLE >
108 bool
110 {
111  (void) c;
112  return false;
113 }
114 
115 
116 #endif // MODM_LOG_STYLE_WRAPPER_HPP
virtual bool read(char &)
Read a single character.
Definition: style_wrapper.hpp:109
virtual void write(char c)
Write a single character.
Definition: style_wrapper.hpp:82
Definition: modm/src/modm/io/iodevice.hpp:26
Wrapper to use the Style as a IODevice in the Logger.
Definition: style_wrapper.hpp:32