X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fconsole.h;h=d29ef003998c005c32d83305003e0b83377a8dd4;hp=54774323558a905d8dbe416114d932fd5e279d83;hb=5b541316a8c7bbf8b812c0f1e2dbebaa6563b0ee;hpb=31e72f50fbb34d86877e5110401c49ce3fefd4bb diff --git a/source/io/console.h b/source/io/console.h index 5477432..d29ef00 100644 --- a/source/io/console.h +++ b/source/io/console.h @@ -1,7 +1,7 @@ #ifndef MSP_IO_CONSOLE_H_ #define MSP_IO_CONSOLE_H_ -#include "base.h" +#include "eventobject.h" #include "handle.h" namespace Msp { @@ -12,12 +12,21 @@ Provides access to standard input, output and error streams. This class can't be instantiated directly - use one of the cin, cout and cerr references instead. */ -class Console: public Base +class Console: public EventObject { +public: + enum Stream + { + INPUT = 0, + OUTPUT = 1, + ERROR = 2 + }; + private: + Stream stream; Handle handle; - Console(unsigned); + Console(Stream); public: ~Console(); @@ -37,6 +46,11 @@ public: Console. */ void get_size(unsigned &rows, unsigned &cols); + /** Redirects input from or output to another I/O object. This performs a + system-level redirect. Closing the other object won't affect the + redirection. */ + void redirect(Base &); + protected: virtual unsigned do_write(const char *, unsigned); virtual unsigned do_read(char *, unsigned); @@ -44,7 +58,7 @@ protected: public: virtual const Handle &get_event_handle() { return handle; } - static Console &instance(unsigned); + static Console &instance(Stream); }; extern Console &cin;