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 */
anonymize the logs
Definition: mythsystem.h:42
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
add arguments for MythTV log propagation
Definition: mythsystem.h:50
unsigned int uint
Definition: compat.h:140
Use parent priority.
Definition: mythsystem.h:93
class for managing sub-processes.
Definition: mythsystem.h:81
disable MythMessage UDP listener for the duration of application.
Definition: mythsystem.h:48
run process through shell
Definition: mythsystem.h:41
automatically delete if backgrounded
Definition: mythsystem.h:43
process events while waiting
Definition: mythsystem.h:37
avoid disabling UI drawing
Definition: mythsystem.h:35
run child in the background
Definition: mythsystem.h:36
run as a normal program
Definition: mythsystem.h:89
MythSignal
Definition: mythsystem.h:54
MythSystemFlag
Definition: mythsystem.h:32
avoid blocking LIRC & Joystick Menu
Definition: mythsystem.h:34
allow exit values 0-127 only
Definition: mythsystem.h:45
allow access to stdin
Definition: mythsystem.h:38
allow access to stderr
Definition: mythsystem.h:40
allow access to stdout
Definition: mythsystem.h:39