Changeset 11053 for trunk/FACT++/src


Ignore:
Timestamp:
06/17/11 09:56:41 (13 years ago)
Author:
tbretz
Message:
Added ConsoleStream class
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Console.cc

    r10922 r11053  
    180180    fLogO.Display(true);
    181181}
     182
     183// **************************************************************************
     184/** @class ConsoleStream
     185
     186@brief This is an extension to the Readline class provding a colored output
     187
     188This in an extension to the Readline class. It's purpose is just to have a
     189colored output stream available. It's main idea is that it is used in
     190environments without user interaction as a replacement the Console class.
     191This is interesting to be able to do everything identical as if Console
     192would be used, but Run() does not prompt but just wait until Stop()
     193was called. The advantage is that some functions of Readline can be used
     194like Execute and the history (just for Execute() commands of course)
     195
     196 */
     197// **************************************************************************
     198
     199
     200// --------------------------------------------------------------------------
     201//
     202//! Instantiate a console stream. It will create a single WindowLog object
     203//! which is returned as input and output stream.
     204//!
     205//! @param name
     206//!     The name of the program passed to the Readline constructor
     207//!
     208ConsoleStream::ConsoleStream(const char *name) : Readline(name)
     209{
     210    ReadlineColor::PrintBootMsg(fLogO, GetName());
     211}
     212
     213// --------------------------------------------------------------------------
     214//
     215//! Just usleep until Stop() was called.
     216//
     217void ConsoleStream::Run(const char *)
     218{
     219    while (!IsStopped())
     220        usleep(10000);
     221}
  • trunk/FACT++/src/Console.h

    r10305 r11053  
    44#include "Readline.h"
    55#include "WindowLog.h"
     6
     7class ConsoleStream : public Readline
     8{
     9private:
     10    WindowLog fLogO;
     11
     12public:
     13    ConsoleStream(const char *name);
     14
     15    // I/O
     16    WindowLog &GetStreamOut() { return fLogO; }
     17    WindowLog &GetStreamIn()  { return fLogO; }
     18
     19    const WindowLog &GetStreamOut() const { return fLogO; }
     20    const WindowLog &GetStreamIn()  const { return fLogO; }
     21
     22    void Run(const char * = 0);
     23};
     24
     25
    626
    727class Console : public Readline
Note: See TracChangeset for help on using the changeset viewer.