feisty meow concerns codebase  2.140
launch_process.h
Go to the documentation of this file.
1 #ifndef LAUNCH_PROCESS_CLASS
2 #define LAUNCH_PROCESS_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : launch_process
7 * Author : Chris Koeritz
8 * *
9 *******************************************************************************
10 * Copyright (c) 1994-$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 <basis/array.h>
19 #include <basis/astring.h>
20 #include <basis/definitions.h>
21 
22 // forward.
23 struct tagMSG;
24 
25 namespace processes {
26 
28 class char_star_array : public basis::array<char *>
29 {
30 public:
33  // clean up all the memory we're holding.
34  for (int i = 0; i < length(); i++) {
35  delete [] (use(i));
36  }
37  }
38 };
39 
41 
43 
44 class launch_process : public virtual basis::nameable
45 {
46 public:
47  DEFINE_CLASS_NAME("launch_process");
48 
49  virtual ~launch_process() {}
50 
51  enum launch_flags {
52  HIDE_APP_WINDOW = 0x1,
54  AWAIT_APP_EXIT = 0x2,
56  RETURN_IMMEDIATELY = 0x4,
58  AWAIT_VIA_POLLING = 0x8,
60  SHELL_EXECUTE = 0x10
62  };
63 
64  static basis::un_int run(const basis::astring &app_name, const basis::astring &command_line,
65  int flag, basis::un_int &child_id);
67 
77  static char_star_array break_line(basis::astring &app, const basis::astring &parameters);
79 
83 private:
84 //#ifndef _MSC_VER
85  static void exiting_child_signal_handler(int sig_num);
87 /*
88 #else
89  static bool event_poll(tagMSG &message);
91  / *!< this is a very general poll and will retrieve any message that's
92  available for the current thread. the message is actually processed
93  here also, by calling translate and dispatch. the returned structure
94  is mainly interesting for knowing what was done. * /
95 #endif
96 */
97 
98 };
99 
100 } // namespace.
101 
102 #endif // outer guard.
103 
Represents a sequential, ordered, contiguous collection of objects.
Definition: array.h:54
@ EXPONE
synonym for EXPONENTIAL_GROWTH.
Definition: array.h:61
@ SIMPLE_COPY
the contents can be memcpy'd and are not deep.
Definition: array.h:59
@ FLUSH_INVISIBLE
blanks out allocated but inaccessible elements.
Definition: array.h:62
int length() const
Returns the current reported length of the allocated C array.
Definition: array.h:115
char * & use(int index)
A non-constant version of get(); the returned object can be modified.
Definition: array.h:365
array(int number=0, const char * *init=NULL_POINTER, int flags=EXPONENTIAL_GROWTH|FLUSH_INVISIBLE)
Constructs an array with room for "number" objects.
Definition: array.h:315
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 simple wrapper of an array of char *, used by launch_process::break_line().
Provides the capability to start processes in a variety of ways to run other applications.
DEFINE_CLASS_NAME("launch_process")
static char_star_array break_line(basis::astring &app, const basis::astring &parameters)
prepares an "app" to launch with the "parameters" (via exec).
@ RETURN_IMMEDIATELY
starts the application and comes right back to the caller.
@ AWAIT_VIA_POLLING
launches the app but polls and doesn't block on its exit.
@ AWAIT_APP_EXIT
stays in the function until the launched application has exited.
@ HIDE_APP_WINDOW
launches the application invisibly if possible.
@ SHELL_EXECUTE
only valid on windows–uses ShellExecute instead of CreateProcess.
static basis::un_int run(const basis::astring &app_name, const basis::astring &command_line, int flag, basis::un_int &child_id)
starts an application using the "app_name" as the executable to run.
Constants and objects used throughout HOOPLE.
#define NULL_POINTER
The value representing a pointer to nothing.
Definition: definitions.h:32
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
unsigned int un_int
Abbreviated name for unsigned integers.
Definition: definitions.h:62