console.hpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Ifdefs
00010 *****************************************************************************/
00011 
00012 #ifndef ECL_DEVICES_CONSOLE_HPP_
00013 #define ECL_DEVICES_CONSOLE_HPP_
00014 
00015 /*****************************************************************************
00016 ** Includes
00017 *****************************************************************************/
00018 
00019 #include "detail/character_buffer.hpp"
00020 #include "traits.hpp"
00021 #include <ecl/errors/handlers.hpp>
00022 #include <ecl/exceptions/standard_exception.hpp>
00023 #include "macros.hpp"
00024 
00025 /*****************************************************************************
00026 ** Namespaces
00027 *****************************************************************************/
00028 
00029 namespace ecl {
00030 
00031 /*****************************************************************************
00032 ** Interface [OConsole]
00033 *****************************************************************************/
00034 
00043 class ecl_devices_PUBLIC OConsole {
00044 public:
00048         OConsole() : error_handler(NoError) {}
00049         virtual ~OConsole() {}
00050 
00051         /*********************
00052         ** Output Device API
00053         **********************/
00062         bool open() { return true; }
00063 
00074         long write(const char &c) ecl_assert_throw_decl(StandardException);
00086         long write(const char* s, unsigned long n) ecl_assert_throw_decl(StandardException);
00093         void flush() ecl_assert_throw_decl(StandardException);
00094 
00103         const Error& error() const { return error_handler; }
00104 private:
00105         devices::CharStringBuffer buffer;
00106         Error error_handler;
00107 };
00108 
00109 /*****************************************************************************
00110 ** Interface [EConsole]
00111 *****************************************************************************/
00112 
00120 class ecl_devices_PUBLIC EConsole {
00121 public:
00125         EConsole() : error_handler(NoError) {}
00126         virtual ~EConsole() {}
00127 
00128         /*********************
00129         ** Output Device API
00130         **********************/
00139         bool open() { return true; }
00140 
00151         long write(const char &c) ecl_assert_throw_decl(StandardException);
00163         long write(const char* s, unsigned long n) ecl_assert_throw_decl(StandardException);
00170         void flush() ecl_assert_throw_decl(StandardException);
00171 
00180         const Error& error() const { return error_handler; }
00181 
00182 private:
00183         devices::CharStringBuffer buffer;
00184         Error error_handler;
00185 };
00186 
00187 /*****************************************************************************
00188 ** Interface [IConsole]
00189 *****************************************************************************/
00190 
00203 class ecl_devices_PUBLIC IConsole {
00204 public:
00208         IConsole() : error_handler(NoError) {}
00209         virtual ~IConsole() {}
00210         /*********************
00211         ** Input Device API
00212         **********************/
00221         bool open() { return true; }
00230     long read(char &c) ecl_assert_throw_decl(StandardException);
00240     long read(char *s, const unsigned long &n) ecl_assert_throw_decl(StandardException);
00241 
00242 //    long remaining() {
00243 //        long pos = ftell(stdin); // get current position marker.
00244 //        fseek(stdin,0,SEEK_END); // move pointer to the end of the file.
00245 //        long size = ftell(stdin);
00246 //        fseek(stdin,pos,SEEK_SET);
00247 //
00248 //        return size;
00249 //    }
00258         const Error& error() const { return error_handler; }
00259 private:
00260         Error error_handler;
00261 };
00262 
00263 
00264 /*****************************************************************************
00265 ** Traits [Console]
00266 *****************************************************************************/
00273 template <>
00274 class is_source<IConsole> : public True {
00275 
00276 };
00277 
00283 template <>
00284 class is_sink<OConsole> : public True {};
00285 
00291 template <>
00292 class is_sink<EConsole> : public True {};
00293 
00294 } // namespace ecl
00295 
00296 #endif /* ECL_DEVICES_CONSOLE_HPP_ */


ecl_devices
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 21:18:03