CConsoleReader.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 // Qt includes
5 #include <QtCore/QThread>
6 
7 
8 namespace iqt
9 {
10 
11 
15 class CConsoleReader: public QObject
16 {
17  Q_OBJECT
18 
19 public:
20  typedef QObject BaseClass;
21 
22  explicit CConsoleReader(QObject* parentPtr = NULL);
23 
27  virtual void Start();
28 
32  virtual void Stop();
33 
37  bool IsRunning() const;
38 
39 signals:
43  void KeyPressedSignal(char character);
44 
45 protected:
46  class InputObserver: public QThread
47  {
48  public:
49  explicit InputObserver(CConsoleReader& parent);
50 
51  void Stop();
52 
53  protected:
54  // reimplemented (QThread)
55  virtual void run();
56 
57  private:
58  CConsoleReader& m_parent;
59  bool m_shouldBeFinished;
60  };
61 
62 private:
63  InputObserver m_inputObserver;
64 };
65 
66 
67 } // namespace iqt
68 
69 
InputObserver(CConsoleReader &parent)
bool IsRunning() const
Check if the reader is running.
CConsoleReader(QObject *parentPtr=NULL)
#define NULL
Definition: istd.h:64
virtual void Stop()
Stop reading of the user input on the console.
virtual void Start()
Start reading of the user input on the console.
void KeyPressedSignal(char character)
Emit typed character.
User-input reader for command line console.

© 2007-2017 Witold Gantzke and Kirill Lepskiy