00001 #ifndef DV_UTIL_TTY_H 00002 #define DV_UTIL_TTY_H 00003 // $Id: tty.h,v 1.7 2008/03/13 21:17:13 dvermeir Exp $ 00004 00005 #include <string> 00006 #include <iostream> 00007 #include <dvutil/debug.h> 00008 00009 /** @file 00010 * This file defines an iostream class ``Tty'' that provides rar 00011 * unbuffered input and output to /dev/tty. 00012 */ 00013 namespace Dv { 00014 namespace Util { 00015 00016 /** 00017 * An iostream class that provides raw unbuffered input and output to 00018 * /dev/tty. 00019 */ 00020 class Tty: public std::iostream, public DebugSlave { 00021 public: 00022 /** Open /dev/tty as an unbuffered stream. 00023 * @param echo if true, characters will be echoed 00024 * @param delay if nonzero, an input operation will fail, and the 00025 * member function timedout() will return true, if no character is 00026 * typed for delay millisecs. 00027 * @param min_debug_level used if the object is connected to 00028 * a debug master 00029 * @sa Dv::Debugable 00030 */ 00031 Tty(bool echo=false, time_t delay = 0, unsigned int min_debug_level = 3); 00032 /** 00033 * Destructor. 00034 */ 00035 ~Tty(); 00036 /** @return true iff the last input operation timedout. This 00037 * condition can be reset using Tty::reset(). 00038 */ 00039 bool timedout() const; 00040 /** Clear the flags and set timedout to false. */ 00041 void reset(); 00042 /** Close the underlying file descriptor. */ 00043 void close(); 00044 private: 00045 bool echo_; 00046 }; 00047 } 00048 } 00049 #endif
dvutil-1.0.10 | [ 5 December, 2009] |