Guitarix
gx_child_process.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  * --------------------------------------------------------------------------
19  */
20 
21 /* ------- This is the Child Processes namespace ------- */
22 
23 #pragma once
24 
25 #ifndef SRC_HEADERS_GX_CHILD_PROCESS_H_
26 #define SRC_HEADERS_GX_CHILD_PROCESS_H_
27 
28 #include <sigc++/sigc++.h>
29 
30 #include <string>
31 #include <list>
32 
33 namespace gx_child_process {
34 
35 class GxChild {
36  public:
37  sigc::signal<void, bool> terminated;
38  bool kill();
39  bool hasPid(pid_t pid) { return pid == m_pid; }
40  bool hasName(string name) { return name == m_name; }
41 
42  private:
43  string m_name;
45  int m_pid;
46  GxChild(string name, int killsignal, int pid):
47  m_name(name), m_killsignal(killsignal), m_pid(pid) {}
48  friend class GxChildProcs;
49 };
50 
51 class GxChildProcs {
52  private:
53  list<GxChild*> children;
54 
55  public:
56  ~GxChildProcs();
57  bool killall();
58  bool kill(string name);
59  GxChild *find(string name);
60  GxChild *launch(string name, const char* const args[], int killsignal);
61  GxChild *launch(string name, list<string> args, int killsignal);
62  friend void gx_sigchld_handler();
63 };
64 
66 void gx_sigchld_handler();
67 
68 
69 /****************************************************************
70  ** classes for UI callbacks
71  */
72 
73 #if false // unused
74 class JackCaptureGui: public sigc::trackable {
75  private:
76  GtkCheckMenuItem *item;
77  void terminated(bool pgm_found);
78  JackCaptureGui(GxChild *p, GtkCheckMenuItem *i);
79  public:
80  static void start_stop(GtkCheckMenuItem *menuitem, gpointer);
81 };
82 
83 class JackCapture: public sigc::trackable {
84  private:
85  GtkToggleButton *button;
86  void terminated(bool pgm_found);
87  static string make_fname(string buf, size_t j, size_t i, int n);
88  static list<string> capture_command(int& seq);
89  JackCapture(GxChild *p, GtkToggleButton *b);
90  public:
91  static void start_stop(GtkWidget *widget, gpointer data);
92  static void stop();
93 };
94 #endif
95 
96 class Meterbridge: public sigc::trackable {
97  private:
98  Glib::RefPtr<ToggleAction> action;
99  void terminated(bool pgm_found);
100  Meterbridge(GxChild *p, Glib::RefPtr<ToggleAction>& a);
101  public:
102  static void start_stop(Glib::RefPtr<ToggleAction>& action, gx_jack::GxJack& jack);
103  static void stop();
104 };
105 
106 /* -------------------------------------------------------------------------- */
107 } /* end of gx_child_process namespace */
108 #endif // SRC_HEADERS_GX_CHILD_PROCESS_H_
GxChild(string name, int killsignal, int pid)
bool hasName(string name)
void gx_sigchld_handler()
sigc::signal< void, bool > terminated
GxChildProcs childprocs
Glib::RefPtr< ToggleAction > action