MythTV  master
mythsystem.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * Class MythSystem
3  *
4  * Copyright (C) Daniel Kristjansson 2013
5  * Copyright (C) Gavin Hurlbut 2012
6  * Copyright (C) Issac Richards 2008
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef MYTHSYSTEM_H_
24 #define MYTHSYSTEM_H_
25 
26 // Qt headers
27 #include <QIODevice>
28 #include <QString>
29 
30 // MythTV headers
31 #include "mythbaseexp.h"
32 #include "mythchrono.h"
33 
35  kMSNone = 0x00000000,
36  kMSDontBlockInputDevs = 0x00000001,
37  kMSDontDisableDrawing = 0x00000002,
38  kMSRunBackground = 0x00000004,
39  kMSProcessEvents = 0x00000008,
40  kMSStdIn = 0x00000020,
41  kMSStdOut = 0x00000040,
42  kMSStdErr = 0x00000080,
43  kMSRunShell = 0x00000200,
44  kMSAnonLog = 0x00000800,
45  kMSAutoCleanup = 0x00004000,
46  kMSLowExitVal = 0x00008000,
48  // ^ FIXME Eliminate? appears to be a hack for some "ubuntu", but
49  // doesn't appear to be needed with ubuntu 12.04
50  kMSDisableUDPListener = 0x00010000,
51  kMSPropagateLogs = 0x00020000,
53 };
55 
56 enum MythSignal {
69 };
70 
81 {
82  public:
84  enum Priority {
85  kIdlePriority = 0,
93  };
94 
95  static MythSystem *Create(
96  const QStringList &args,
97  uint flags = kMSNone,
98  const QString& startPath = QString(),
99  Priority cpuPriority = kInheritPriority,
100  Priority diskPriority = kInheritPriority);
101 
102  static MythSystem *Create(
103  const QString& args,
104  uint flags = kMSNone,
105  const QString& startPath = QString(),
106  Priority cpuPriority = kInheritPriority,
107  Priority diskPriority = kInheritPriority);
108 
109  virtual ~MythSystem(void) = default;
110 
111  // Deleted functions should be public.
112  MythSystem(const MythSystem&) = delete; // no-implementation
113  MythSystem& operator= (const MythSystem&) = delete; // no-implementation
114 
116  virtual uint GetFlags(void) const = 0;
117 
119  virtual QString GetStartingPath(void) const = 0;
120 
122  virtual Priority GetCPUPriority(void) const = 0;
123 
125  virtual Priority GetDiskPriority(void) const = 0;
126 
132  virtual bool Wait(std::chrono::milliseconds timeout = 0ms) = 0;
133 
137  virtual QIODevice *GetStandardInputStream(void) = 0;
138 
142  virtual QIODevice *GetStandardOutputStream(void) = 0;
143 
147  virtual QIODevice *GetStandardErrorStream(void) = 0;
148 
150  virtual void Signal(MythSignal) = 0;
151 
158  virtual int GetExitCode(void) const = 0;
159 
160  protected:
161  MythSystem() = default;
162 };
163 
164 #endif // MYTHSYSTEM_H_
165 
166 /* vim:ts=4:sw=4:ai:et:si:sts=4 */
kMSStdErr
@ kMSStdErr
allow access to stderr
Definition: mythsystem.h:42
kSignalNone
@ kSignalNone
Definition: mythsystem.h:57
MythSystem::kLowPriority
@ kLowPriority
Definition: mythsystem.h:87
build_compdb.args
args
Definition: build_compdb.py:11
kSignalStop
@ kSignalStop
Definition: mythsystem.h:68
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
kMSDontBlockInputDevs
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
Definition: mythsystem.h:36
kMSAnonLog
@ kMSAnonLog
anonymize the logs
Definition: mythsystem.h:44
MythSystem::kHighestPriority
@ kHighestPriority
Definition: mythsystem.h:90
MythSystem
class for managing sub-processes.
Definition: mythsystem.h:80
mythbaseexp.h
kSignalQuit
@ kSignalQuit
Definition: mythsystem.h:62
MythSystem::kTimeCriticalPriority
@ kTimeCriticalPriority
Definition: mythsystem.h:91
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythSystem::kLowestPriority
@ kLowestPriority
Definition: mythsystem.h:86
kSignalUnknown
@ kSignalUnknown
Definition: mythsystem.h:58
kSignalContinue
@ kSignalContinue
Definition: mythsystem.h:61
kMSPropagateLogs
@ kMSPropagateLogs
add arguments for MythTV log propagation
Definition: mythsystem.h:52
uint
unsigned int uint
Definition: compat.h:140
kMSRunShell
@ kMSRunShell
run process through shell
Definition: mythsystem.h:43
kMSAutoCleanup
@ kMSAutoCleanup
automatically delete if backgrounded
Definition: mythsystem.h:45
kMSRunBackground
@ kMSRunBackground
run child in the background
Definition: mythsystem.h:38
kSignalInterrupt
@ kSignalInterrupt
Definition: mythsystem.h:60
kMSDisableUDPListener
@ kMSDisableUDPListener
disable MythMessage UDP listener for the duration of application.
Definition: mythsystem.h:50
kSignalUser1
@ kSignalUser1
Definition: mythsystem.h:65
kSignalKill
@ kSignalKill
Definition: mythsystem.h:64
MythSystemFlag
MythSystemFlag
Definition: mythsystem.h:34
kMSNone
@ kMSNone
Definition: mythsystem.h:35
kMSProcessEvents
@ kMSProcessEvents
process events while waiting
Definition: mythsystem.h:39
kMSLowExitVal
@ kMSLowExitVal
allow exit values 0-127 only
Definition: mythsystem.h:47
MythSignal
MythSignal
Definition: mythsystem.h:56
mythchrono.h
MythSystem::kNormalPriority
@ kNormalPriority
run as a normal program
Definition: mythsystem.h:88
kMSDontDisableDrawing
@ kMSDontDisableDrawing
avoid disabling UI drawing
Definition: mythsystem.h:37
kSignalHangup
@ kSignalHangup
Definition: mythsystem.h:59
kMSStdIn
@ kMSStdIn
allow access to stdin
Definition: mythsystem.h:40
kSignalUser2
@ kSignalUser2
Definition: mythsystem.h:66
MythSystem::kInheritPriority
@ kInheritPriority
Use parent priority.
Definition: mythsystem.h:92
kSignalTerm
@ kSignalTerm
Definition: mythsystem.h:67
kMSStdOut
@ kMSStdOut
allow access to stdout
Definition: mythsystem.h:41
Priority
Definition: channelsettings.cpp:191
kSignalSegfault
@ kSignalSegfault
Definition: mythsystem.h:63
MythSystem::kHighPriority
@ kHighPriority
Definition: mythsystem.h:89