MythTV  master
scanmonitor.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * vim: set expandtab tabstop=4 shiftwidth=4:
3  *
4  * Original Project
5  * MythTV http://www.mythtv.org
6  *
7  * Copyright (c) 2004, 2005 John Pullan <john@pullan.org>
8  * Copyright (c) 2005 - 2007 Daniel Kristjansson
9  *
10  * Description:
11  * Collection of classes to provide channel scanning functionallity
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27  *
28  */
29 
30 #ifndef _SCAN_MONITOR_H_
31 #define _SCAN_MONITOR_H_
32 
33 // Qt headers
34 #include <QObject>
35 #include <QEvent>
36 
37 // MythTV headers
38 #include "signalmonitorlistener.h"
39 
40 class ChannelScanner;
41 class SignalMonitorValue;
42 class QString;
43 
44 class ScanMonitor :
45  public QObject,
47 {
48  Q_OBJECT
49 
50  friend class QObject; // quiet OSX gcc warning
51 
52  public:
54  virtual void deleteLater(void);
55 
56  void customEvent(QEvent*) override; // QObject
57 
58  // Values from 1-100 of scan completion
59  void ScanPercentComplete(int pct);
60  void ScanUpdateStatusText(const QString &status);
61  void ScanUpdateStatusTitleText(const QString &status);
62  void ScanAppendTextToLog(const QString &status);
63  void ScanComplete(void);
64  void ScanErrored(const QString &error);
65 
66  // SignalMonitorListener
67  void AllGood(void) override { } // SignalMonitorListener
68  void StatusSignalLock(const SignalMonitorValue&) override; // SignalMonitorListener
69  void StatusChannelTuned(const SignalMonitorValue&) override; // SignalMonitorListener
70  void StatusSignalStrength(const SignalMonitorValue&) override; // SignalMonitorListener
71 
72  // DVBSignalMonitorListener
73  void StatusSignalToNoise(const SignalMonitorValue&) override; // DVBSignalMonitorListener
74  void StatusBitErrorRate(const SignalMonitorValue&) override { } // DVBSignalMonitorListener
75  void StatusUncorrectedBlocks(const SignalMonitorValue&) override { } // DVBSignalMonitorListener
76  void StatusRotorPosition(const SignalMonitorValue&) override; // DVBSignalMonitorListener
77 
78  private:
79  ~ScanMonitor() = default;
80 
82 };
83 
84 class Configurable;
85 
86 class ScannerEvent : public QEvent
87 {
88  friend class QObject; // quiet OSX gcc warning
89 
90  public:
91 
92  explicit ScannerEvent(QEvent::Type type) : QEvent(type) { }
93 
94  QString strValue() const { return m_str; }
95  void strValue(const QString& str) { m_str = str; }
96 
97  int intValue() const { return m_intvalue; }
98  void intValue(int intvalue) { m_intvalue = intvalue; }
99 
100  int boolValue() const { return m_intvalue != 0; }
101 
102  Configurable *ConfigurableValue() const { return m_cfg_ptr; }
103  void ConfigurableValue(Configurable *cfg_ptr)
104  { m_cfg_ptr = cfg_ptr; }
105 
106  static Type ScanComplete;
107  static Type ScanShutdown;
108  static Type ScanErrored;
109  static Type AppendTextToLog;
110  static Type SetStatusText;
111  static Type SetStatusTitleText;
112  static Type SetPercentComplete;
116  static Type SetStatusSignalLock;
118 
119  private:
120  ~ScannerEvent() = default;
121 
122  private:
123  QString m_str;
124  int m_intvalue {0};
125  Configurable *m_cfg_ptr {nullptr};
126 };
127 
128 void post_event(QObject *dest, QEvent::Type type, int val);
129 void post_event(QObject *dest, QEvent::Type type, const QString &val);
130 void post_event(QObject *dest, QEvent::Type type, int val,
131  Configurable *spp);
132 
133 #endif // _SCAN_MONITOR_H_
static Type SetStatusText
Definition: scanmonitor.h:110
void StatusSignalToNoise(const SignalMonitorValue &) override
void ScanUpdateStatusTitleText(const QString &status)
static Type SetStatusSignalStrength
Definition: scanmonitor.h:115
void StatusSignalStrength(const SignalMonitorValue &) override
Signal to be sent with an actual signal value.
void AllGood(void) override
Signal to be sent when you have a lock on all values.
Definition: scanmonitor.h:67
static void error(const char *str,...)
Definition: vbi.c:42
static Type SetStatusTitleText
Definition: scanmonitor.h:111
void StatusRotorPosition(const SignalMonitorValue &) override
ScanMonitor(ChannelScanner *cs)
Definition: scanmonitor.h:53
static Type AppendTextToLog
Definition: scanmonitor.h:109
static Type SetPercentComplete
Definition: scanmonitor.h:112
QString m_str
Definition: scanmonitor.h:123
~ScannerEvent()=default
void ScanPercentComplete(int pct)
virtual void deleteLater(void)
Definition: scanmonitor.cpp:91
void ConfigurableValue(Configurable *cfg_ptr)
Definition: scanmonitor.h:103
void strValue(const QString &str)
Definition: scanmonitor.h:95
friend class QObject
Definition: scanmonitor.h:88
static Type ScanComplete
Definition: scanmonitor.h:106
static Type ScanShutdown
Definition: scanmonitor.h:107
void ScanErrored(const QString &error)
QString strValue() const
Definition: scanmonitor.h:94
static Type SetStatusChannelTuned
Definition: scanmonitor.h:117
~ScanMonitor()=default
ScannerEvent(QEvent::Type type)
Definition: scanmonitor.h:92
static Type SetStatusRotorPosition
Definition: scanmonitor.h:113
void post_event(QObject *dest, QEvent::Type type, int val)
Definition: scanmonitor.cpp:68
void StatusBitErrorRate(const SignalMonitorValue &) override
Definition: scanmonitor.h:74
void ScanAppendTextToLog(const QString &status)
friend class QObject
Definition: scanmonitor.h:50
static Type ScanErrored
Definition: scanmonitor.h:108
static Type SetStatusSignalToNoise
Definition: scanmonitor.h:114
int intValue() const
Definition: scanmonitor.h:97
void StatusUncorrectedBlocks(const SignalMonitorValue &) override
Definition: scanmonitor.h:75
void intValue(int intvalue)
Definition: scanmonitor.h:98
Configurable * m_cfg_ptr
Definition: scanmonitor.h:125
void StatusChannelTuned(const SignalMonitorValue &) override
Signal to be sent with change change status.
Configurable * ConfigurableValue() const
Definition: scanmonitor.h:102
static Type SetStatusSignalLock
Definition: scanmonitor.h:116
void ScanComplete(void)
Definition: scanmonitor.cpp:98
void customEvent(QEvent *) override
int boolValue() const
Definition: scanmonitor.h:100
ChannelScanner * m_channelScanner
Definition: scanmonitor.h:81
void StatusSignalLock(const SignalMonitorValue &) override
Signal to be sent as true when it is safe to begin or continue recording, and false if it may not be ...
void ScanUpdateStatusText(const QString &status)