console.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_DEVICES_CONSOLE_HPP_
13 #define ECL_DEVICES_CONSOLE_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
20 #include "traits.hpp"
21 #include <ecl/errors/handlers.hpp>
23 #include "macros.hpp"
24 
25 /*****************************************************************************
26 ** Namespaces
27 *****************************************************************************/
28 
29 namespace ecl {
30 
31 /*****************************************************************************
32 ** Interface [OConsole]
33 *****************************************************************************/
34 
44 public:
48  OConsole() : error_handler(NoError) {}
49  virtual ~OConsole() {}
50 
51  /*********************
52  ** Output Device API
53  **********************/
62  bool open() { return true; }
63 
74  long write(const char &c) ecl_assert_throw_decl(StandardException);
86  long write(const char* s, unsigned long n) ecl_assert_throw_decl(StandardException);
93  void flush() ecl_assert_throw_decl(StandardException);
94 
103  const Error& error() const { return error_handler; }
104 private:
107 };
108 
109 /*****************************************************************************
110 ** Interface [EConsole]
111 *****************************************************************************/
112 
121 public:
125  EConsole() : error_handler(NoError) {}
126  virtual ~EConsole() {}
127 
128  /*********************
129  ** Output Device API
130  **********************/
139  bool open() { return true; }
140 
151  long write(const char &c) ecl_assert_throw_decl(StandardException);
163  long write(const char* s, unsigned long n) ecl_assert_throw_decl(StandardException);
170  void flush() ecl_assert_throw_decl(StandardException);
171 
180  const Error& error() const { return error_handler; }
181 
182 private:
185 };
186 
187 /*****************************************************************************
188 ** Interface [IConsole]
189 *****************************************************************************/
190 
204 public:
208  IConsole() : error_handler(NoError) {}
209  virtual ~IConsole() {}
210  /*********************
211  ** Input Device API
212  **********************/
221  bool open() { return true; }
230  long read(char &c) ecl_assert_throw_decl(StandardException);
240  long read(char *s, const unsigned long &n) ecl_assert_throw_decl(StandardException);
241 
242 // long remaining() {
243 // long pos = ftell(stdin); // get current position marker.
244 // fseek(stdin,0,SEEK_END); // move pointer to the end of the file.
245 // long size = ftell(stdin);
246 // fseek(stdin,pos,SEEK_SET);
247 //
248 // return size;
249 // }
258  const Error& error() const { return error_handler; }
259 private:
261 };
262 
263 
264 /*****************************************************************************
265 ** Traits [Console]
266 *****************************************************************************/
273 template <>
274 class is_source<IConsole> : public True {
275 
276 };
277 
283 template <>
284 class is_sink<OConsole> : public True {};
285 
291 template <>
292 class is_sink<EConsole> : public True {};
293 
294 } // namespace ecl
295 
296 #endif /* ECL_DEVICES_CONSOLE_HPP_ */
Default action for detection of source devices (input) (false).
Definition: traits.hpp:39
const Error & error() const
Returns the most recent error status.
Definition: console.hpp:103
Embedded control libraries.
Error error_handler
Definition: console.hpp:260
bool open()
Dummy handle to satisfy the output device concept.
Definition: console.hpp:139
Error error_handler
Definition: console.hpp:106
virtual ~OConsole()
Definition: console.hpp:49
A generic buffer for devices.
Traits for devices.
Device for writing to standard output.
Definition: console.hpp:43
bool open()
Dummy handle to satisfy the output device concept.
Definition: console.hpp:62
const Error & error() const
Returns the most recent error status.
Definition: console.hpp:180
const Error & error() const
Returns the most recent error status.
Definition: console.hpp:258
virtual ~EConsole()
Definition: console.hpp:126
OConsole()
Default constructor.
Definition: console.hpp:48
bool open()
Dummy handle to satisfy the input device concept.
Definition: console.hpp:221
Macros for ecl devices.
EConsole()
Default constructor.
Definition: console.hpp:125
Device for reading from standard output.
Definition: console.hpp:203
virtual ~IConsole()
Definition: console.hpp:209
#define ecl_assert_throw_decl(exception)
Simple char string buffer class for use internally by the devices.
#define ecl_devices_PUBLIC
Definition: macros.hpp:37
Device for writing o standard error.
Definition: console.hpp:120
IConsole()
Default constructor.
Definition: console.hpp:208
Default action for detection of sink devices (output) (false).
Definition: traits.hpp:50
Error error_handler
Definition: console.hpp:184
devices::CharStringBuffer buffer
Definition: console.hpp:183
devices::CharStringBuffer buffer
Definition: console.hpp:105


ecl_devices
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:45