feisty meow concerns codebase  2.140
process_control.h
Go to the documentation of this file.
1 #ifndef PROCESS_CONTROL_CLASS
2 #define PROCESS_CONTROL_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : process_control *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 2000-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
18 #include "process_entry.h"
19 
20 #include <basis/contracts.h>
21 #include <mathematics/chaos.h>
22 #include <structures/set.h>
23 
24 namespace processes {
25 
26 // forward.
27 class process_entry_array;
28 class process_implementation_hider;
29 
31 
36 class process_control : public virtual basis::nameable
37 {
38 public:
40  virtual ~process_control();
41 
42  DEFINE_CLASS_NAME("process_control");
43 
44  bool healthy() const { return _healthy; }
46 
52 
53  bool query_processes(process_entry_array &to_fill);
55 
56  bool zap_process(basis::un_int to_zap);
58 
62  const basis::astring &app_name, structures::int_set &pids);
64 
70  void sort_by_name(process_entry_array &to_sort);
71  // sorts the list by process name.
72  void sort_by_pid(process_entry_array &to_sort);
73  // sorts the list by process id.
74 
75 private:
76  process_implementation_hider *_ptrs;
77 //#ifndef _MSC_VER
78  mathematics::chaos *_rando;
79 //#else
80  //bool _use_psapi; //!< true if we should be using the PSAPI on NT and family.
81 //#endif
82  bool _healthy;
83 
84 //#ifndef _MSC_VER
85  bool get_processes_with_ps(process_entry_array &to_fill);
87 /*
88 #else
89  // fill in our function pointers to access the kernel functions appropriate
90  // for either NT (psapi) or 9x (toolhelp).
91  bool initialize_psapi_support();
92  bool initialize_toolhelp_support();
93 
94  bool get_processes_with_psapi(process_entry_array &to_fill);
96  bool get_processes_with_toolhelp(process_entry_array &to_fill);
98 #endif
99 */
100 };
101 
102 } //namespace.
103 
104 #endif // outer guard.
105 
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
Root object for any class that knows its own name.
Definition: contracts.h:123
a platform-independent way to acquire random numbers in a specific range.
Definition: chaos.h:51
Provides a bridge to the operating system for information on processes.
static bool find_process_in_list(const process_entry_array &processes, const basis::astring &app_name, structures::int_set &pids)
uses a pre-existing list of "processes" to search for the "app_name".
void sort_by_pid(process_entry_array &to_sort)
process_entry query_process(basis::un_int to_query)
returns the information for just one process.
bool zap_process(basis::un_int to_zap)
preemptively zaps the process "to_zap".
DEFINE_CLASS_NAME("process_control")
bool healthy() const
returns true if this object should be functional.
void sort_by_name(process_entry_array &to_sort)
bool query_processes(process_entry_array &to_fill)
finds the processes that are running and drops them into "to_fill".
a handy class that implements an array of process entries.
Definition: process_entry.h:60
Encapsulates information about OS processes.
Definition: process_entry.h:28
A simple object that wraps a templated set of ints.
Definition: set.h:156
unsigned int un_int
Abbreviated name for unsigned integers.
Definition: definitions.h:62