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 
32 typedef enum MythSystemMask {
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,
53 
54 typedef enum MythSignal {
67 } MythSignal;
68 
69 class QStringList;
70 class QIODevice;
71 
82 {
83  public:
85  typedef enum Priority {
86  kIdlePriority = 0,
94  } Priority;
95 
96  static MythSystem *Create(
97  const QStringList &args,
98  uint flags = kMSNone,
99  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  QString startPath = QString(),
107  Priority cpuPriority = kInheritPriority,
108  Priority diskPriority = kInheritPriority);
109 
110  virtual ~MythSystem(void) = default;
111 
113  virtual uint GetFlags(void) const = 0;
114 
116  virtual QString GetStartingPath(void) const = 0;
117 
119  virtual Priority GetCPUPriority(void) const = 0;
120 
122  virtual Priority GetDiskPriority(void) const = 0;
123 
129  virtual bool Wait(uint timeout_ms = 0) = 0;
130 
134  virtual QIODevice *GetStandardInputStream(void) = 0;
135 
139  virtual QIODevice *GetStandardOutputStream(void) = 0;
140 
144  virtual QIODevice *GetStandardErrorStream(void) = 0;
145 
147  virtual void Signal(MythSignal) = 0;
148 
155  virtual int GetExitCode(void) const = 0;
156 
157  protected:
158  MythSystem() = default;
159 
160  private:
161  MythSystem(const MythSystem&); // no-implementation
162  MythSystem& operator= (const MythSystem&); // no-implementation
163 };
164 
165 #endif // MYTHSYSTEM_H_
166 
167 /* vim:ts=4:sw=4:ai:et:si:sts=4 */
avoid disabling UI drawing
Definition: mythsystem.h:35
allow access to stdin
Definition: mythsystem.h:38
automatically delete if backgrounded
Definition: mythsystem.h:43
allow access to stdout
Definition: mythsystem.h:39
run child in the background
Definition: mythsystem.h:36
unsigned int uint
Definition: compat.h:140
process events while waiting
Definition: mythsystem.h:37
add arguments for MythTV log propagation
Definition: mythsystem.h:50
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythSystemMask
Definition: mythsystem.h:32
anonymize the logs
Definition: mythsystem.h:42
allow exit values 0-127 only
Definition: mythsystem.h:45
run process through shell
Definition: mythsystem.h:41
allow access to stderr
Definition: mythsystem.h:40
disable MythMessage UDP listener for the duration of application.
Definition: mythsystem.h:48
Use parent priority.
Definition: mythsystem.h:93
class for managing sub-processes.
Definition: mythsystem.h:81
run as a normal program
Definition: mythsystem.h:89
MythSignal
Definition: mythsystem.h:54
avoid blocking LIRC & Joystick Menu
Definition: mythsystem.h:34