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 <QString>
28 
29 // MythTV headers
30 #include "mythbaseexp.h"
31 
33  kMSNone = 0x00000000,
34  kMSDontBlockInputDevs = 0x00000001,
35  kMSDontDisableDrawing = 0x00000002,
36  kMSRunBackground = 0x00000004,
37  kMSProcessEvents = 0x00000008,
38  kMSStdIn = 0x00000020,
39  kMSStdOut = 0x00000040,
40  kMSStdErr = 0x00000080,
41  kMSRunShell = 0x00000200,
42  kMSAnonLog = 0x00000800,
43  kMSAutoCleanup = 0x00004000,
44  kMSLowExitVal = 0x00008000,
46  // ^ FIXME Eliminate? appears to be a hack for some "ubuntu", but
47  // doesn't appear to be needed with ubuntu 12.04
48  kMSDisableUDPListener = 0x00010000,
49  kMSPropagateLogs = 0x00020000,
51 };
53 
54 enum MythSignal {
67 };
68 
69 class QStringList;
70 class QIODevice;
71 
82 {
83  public:
85  enum Priority {
86  kIdlePriority = 0,
94  };
95 
96  static MythSystem *Create(
97  const QStringList &args,
98  uint flags = kMSNone,
99  const QString& startPath = QString(),
100  Priority cpuPriority = kInheritPriority,
101  Priority diskPriority = kInheritPriority);
102 
103  static MythSystem *Create(
104  const QString& args,
105  uint flags = kMSNone,
106  const QString& startPath = QString(),
107  Priority cpuPriority = kInheritPriority,
108  Priority diskPriority = kInheritPriority);
109 
110  virtual ~MythSystem(void) = default;
111 
112  // Deleted functions should be public.
113  MythSystem(const MythSystem&) = delete; // no-implementation
114  MythSystem& operator= (const MythSystem&) = delete; // no-implementation
115 
117  virtual uint GetFlags(void) const = 0;
118 
120  virtual QString GetStartingPath(void) const = 0;
121 
123  virtual Priority GetCPUPriority(void) const = 0;
124 
126  virtual Priority GetDiskPriority(void) const = 0;
127 
133  virtual bool Wait(uint timeout_ms = 0) = 0;
134 
138  virtual QIODevice *GetStandardInputStream(void) = 0;
139 
143  virtual QIODevice *GetStandardOutputStream(void) = 0;
144 
148  virtual QIODevice *GetStandardErrorStream(void) = 0;
149 
151  virtual void Signal(MythSignal) = 0;
152 
159  virtual int GetExitCode(void) const = 0;
160 
161  protected:
162  MythSystem() = default;
163 };
164 
165 #endif // MYTHSYSTEM_H_
166 
167 /* vim:ts=4:sw=4:ai:et:si:sts=4 */
kMSStdErr
@ kMSStdErr
allow access to stderr
Definition: mythsystem.h:40
kSignalNone
@ kSignalNone
Definition: mythsystem.h:55
MythSystem::kLowPriority
@ kLowPriority
Definition: mythsystem.h:88
MythSystem::MythSystem
MythSystem(const MythSystem &)=delete
build_compdb.args
args
Definition: build_compdb.py:11
kSignalStop
@ kSignalStop
Definition: mythsystem.h:66
kMSDontBlockInputDevs
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
Definition: mythsystem.h:34
kMSAnonLog
@ kMSAnonLog
anonymize the logs
Definition: mythsystem.h:42
MythSystem::kHighestPriority
@ kHighestPriority
Definition: mythsystem.h:91
MythSystem
class for managing sub-processes.
Definition: mythsystem.h:82
mythbaseexp.h
kSignalQuit
@ kSignalQuit
Definition: mythsystem.h:60
MythSystem::MythSystem
MythSystem()=default
MythSystem::kTimeCriticalPriority
@ kTimeCriticalPriority
Definition: mythsystem.h:92
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythSystem::Wait
virtual bool Wait(uint timeout_ms=0)=0
Blocks until child process is collected or timeout reached.
MythSystem::GetStandardInputStream
virtual QIODevice * GetStandardInputStream(void)=0
Returns the standard input stream for the program if the kMSStdIn flag was passed to the constructor.
MythSystem::GetStandardErrorStream
virtual QIODevice * GetStandardErrorStream(void)=0
Returns the standard error stream for the program if the kMSStdErr flag was passed to the constructor...
MythSystem::GetDiskPriority
virtual Priority GetDiskPriority(void) const =0
Return the Disk Priority of the program.
MythSystem::kLowestPriority
@ kLowestPriority
Definition: mythsystem.h:87
kSignalUnknown
@ kSignalUnknown
Definition: mythsystem.h:56
kSignalContinue
@ kSignalContinue
Definition: mythsystem.h:59
MythSystem::~MythSystem
virtual ~MythSystem(void)=default
kMSPropagateLogs
@ kMSPropagateLogs
add arguments for MythTV log propagation
Definition: mythsystem.h:50
uint
unsigned int uint
Definition: compat.h:140
kMSRunShell
@ kMSRunShell
run process through shell
Definition: mythsystem.h:41
kMSAutoCleanup
@ kMSAutoCleanup
automatically delete if backgrounded
Definition: mythsystem.h:43
kMSRunBackground
@ kMSRunBackground
run child in the background
Definition: mythsystem.h:36
kSignalInterrupt
@ kSignalInterrupt
Definition: mythsystem.h:58
MythSystem::GetFlags
virtual uint GetFlags(void) const =0
Returns the flags passed to the constructor.
kMSDisableUDPListener
@ kMSDisableUDPListener
disable MythMessage UDP listener for the duration of application.
Definition: mythsystem.h:48
kSignalUser1
@ kSignalUser1
Definition: mythsystem.h:63
kSignalKill
@ kSignalKill
Definition: mythsystem.h:62
MythSystemFlag
MythSystemFlag
Definition: mythsystem.h:32
kMSNone
@ kMSNone
Definition: mythsystem.h:33
kMSProcessEvents
@ kMSProcessEvents
process events while waiting
Definition: mythsystem.h:37
MythSystem::GetStartingPath
virtual QString GetStartingPath(void) const =0
Returns the starting path of the program.
kMSLowExitVal
@ kMSLowExitVal
allow exit values 0-127 only
Definition: mythsystem.h:45
MythSignal
MythSignal
Definition: mythsystem.h:54
MythSystem::GetStandardOutputStream
virtual QIODevice * GetStandardOutputStream(void)=0
Returns the standard output stream for the program if the kMSStdOut flag was passed to the constructo...
MythSystem::Signal
virtual void Signal(MythSignal)=0
Sends the selected signal to the program.
MythSystem::GetExitCode
virtual int GetExitCode(void) const =0
returns the exit code, if any, that the program returned.
MythSystem::kNormalPriority
@ kNormalPriority
run as a normal program
Definition: mythsystem.h:89
kMSDontDisableDrawing
@ kMSDontDisableDrawing
avoid disabling UI drawing
Definition: mythsystem.h:35
MythSystem::GetCPUPriority
virtual Priority GetCPUPriority(void) const =0
Return the CPU Priority of the program.
kSignalHangup
@ kSignalHangup
Definition: mythsystem.h:57
kMSStdIn
@ kMSStdIn
allow access to stdin
Definition: mythsystem.h:38
kSignalUser2
@ kSignalUser2
Definition: mythsystem.h:64
MythSystem::kInheritPriority
@ kInheritPriority
Use parent priority.
Definition: mythsystem.h:93
kSignalTerm
@ kSignalTerm
Definition: mythsystem.h:65
kMSStdOut
@ kMSStdOut
allow access to stdout
Definition: mythsystem.h:39
Priority
Definition: channelsettings.cpp:192
kSignalSegfault
@ kSignalSegfault
Definition: mythsystem.h:61
MythSystem::kHighPriority
@ kHighPriority
Definition: mythsystem.h:90