process_manager.h

Go to the documentation of this file.
00001 #ifndef PROCESS_MANAGER_CLASS
00002 #define PROCESS_MANAGER_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : process_manager                                                   *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2000-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "dll_processes.h"
00019 
00020 #include <basis/object_base.h>
00021 
00022 // forward.
00023 class application_config;
00024 class graceful_array;
00025 class istring;
00026 class int_set;
00027 class mutex;
00028 class outcome;
00029 class process_manager_thread;
00030 class process_entry_array;
00031 class process_control;
00032 class string_set;
00033 class time_stamp;
00034 
00036 
00041 class PROCESSES_CLASS_STYLE process_manager
00042 {
00043 public:
00044   process_manager(application_config &config);
00046 
00047   virtual ~process_manager();
00048 
00049   IMPLEMENT_CLASS_NAME("process_manager");
00050 
00051   enum outcomes {
00052     OKAY = common::OKAY,
00053     EXISTING = common::EXISTING,
00055     ACCESS_DENIED = common::ACCESS_DENIED,
00057 
00058     DEFINE_API_OUTCOME(FILE_NOT_FOUND, -53, "The file specified for the "
00059         "application doesn't exist, as far as we can tell"),
00060     FIRST_OUTCOME = FILE_NOT_FOUND,  // hold onto start of range.
00061     DEFINE_API_OUTCOME(NO_PRODUCT, -54, "The product specified does not exist"),
00062     DEFINE_API_OUTCOME(NO_APPLICATION, -55, "The application is not listed for "
00063         "the product"),
00064     DEFINE_API_OUTCOME(NOT_RUNNING, -56, "The program is not currently active, "
00065         "according to the OS process list"),
00066     DEFINE_API_OUTCOME(BAD_PROGRAM, -57, "The file existed but doesn't appear "
00067         "to be a valid program image"),
00068     DEFINE_API_OUTCOME(NO_ANCHOR, -58, "This occurs when the graceful shutdown "
00069         "process cannot find the special anchor window that implements the "
00070         "client side of a graceful shutdown"),
00071     DEFINE_API_OUTCOME(LAUNCH_FAILED, -59, "The program existed and seemed "
00072         "valid but its launch failed for some reason"),
00073     DEFINE_API_OUTCOME(FROZEN, -60, "The application is broken somehow; the "
00074         "system reports it as non-responsive"),
00075     LAST_OUTCOME = FROZEN  // hold onto end of range.
00076   };
00077 
00078   static const char *outcome_name(const outcome &to_name);
00080 
00081   outcome launch_now(const istring &product, const istring &app_name,
00082           const istring &parameters);
00084 
00089   outcome launch_at_startup(const istring &product, const istring &app_name,
00090           const istring &parameters, int one_shot);
00092 
00095   outcome remove_from_startup(const istring &product, const istring &app_name);
00097 
00098   outcome query_application(const istring &product, const istring &app_name);
00100 
00101   outcome zap_process(const istring &product, const istring &app_name,
00102           bool graceful);
00104 
00107   void add_gag_exclusion(const istring &exclusion);
00109 
00111   void add_tracking_exclusion(const istring &exclusion);
00113 
00116   outcome shut_down_launching_services(const istring &secret_word);
00118 
00123   outcome reenable_launching_services(const istring &secret_word);
00125 
00127   bool services_disabled() const { return _stop_launching; }
00129 
00130   void push_timed_activities(process_entry_array &processes);
00132 
00135   void stop_everything();
00137 
00138 private:
00139   application_config &_configs;  
00140   bool _started_initial_apps;  
00141   process_manager_thread *_checker;  
00142   mutex *_config_lock;  
00143   graceful_array *_going_down;  
00144   mutex *_zombie_lock;  
00145   graceful_array *_our_kids;  
00146   mutex *_scamp_lock;  
00147   bool _stop_launching;  
00148   time_stamp *_startup_time;
00150 
00152   process_control *_procs;  
00153   string_set *_gag_exclusions;  
00154   string_set *_tracking_exclusions;  
00155 
00156   bool get_processes(process_entry_array &processes);
00158 
00159   bool find_process(const istring &app_name, int_set &pids);
00161 
00162   outcome start_graceful_close(const istring &product, const istring &app_name);
00164 
00167   void launch_startup_apps();
00169 
00170   void stop_all_kids();
00172 };
00173 
00174 #endif
00175 

Generated on Fri Nov 21 04:29:57 2008 for HOOPLE Libraries by  doxygen 1.5.1