]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/console.h
Add decorations for things which are considered part of the API
[libs/core.git] / source / io / console.h
index 5b4158fc90b533a96d7399da08d41d45b7887b30..1755659f9f5b3c0d7e93d3670decf4157d034fdb 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_IO_CONSOLE_H_
 #define MSP_IO_CONSOLE_H_
 
+#include <msp/core/mspcore_api.h>
 #include "eventobject.h"
 #include "handle.h"
 
@@ -12,14 +13,14 @@ 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 EventObject
+class MSPCORE_API Console: public EventObject
 {
 public:
        enum Stream
        {
-               INPUT = 0,
-               OUTPUT = 1,
-               ERROR = 2
+               CIN = 0,
+               COUT = 1,
+               CERR = 2
        };
 
 private:
@@ -27,10 +28,12 @@ private:
        Handle handle;
 
        Console(Stream);
+       void platform_init();
 public:
        ~Console();
 
-       virtual void set_block(bool);
+       void set_block(bool) override;
+       void set_inherit(bool) override;
        
        /** If local echo is enabled, characters will appear on the console as they
        are typed.  Can only be used on an input Console.  */
@@ -46,19 +49,25 @@ 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);
+       std::size_t do_write(const char *, std::size_t) override;
+       std::size_t do_read(char *, std::size_t) override;
 
 public:
-       virtual const Handle &get_event_handle() { return handle; }
+       const Handle &get_handle(Mode) override;
+       const Handle &get_event_handle() override { return handle; }
 
        static Console &instance(Stream);
 };
 
-extern Console &cin;
-extern Console &cout;
-extern Console &cerr;
+MSPCORE_API extern Console &cin;
+MSPCORE_API extern Console &cout;
+MSPCORE_API extern Console &cerr;
 
 } // namespace IO
 } // namespace Msp