FreeNOS
ApplicationLauncher.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIB_LIBAPP_APPLICATIONLAUNCHER_H
19 #define __LIB_LIBAPP_APPLICATIONLAUNCHER_H
20 
21 #include <Types.h>
22 #include <String.h>
23 
36 {
37  public:
38 
42  enum Result
43  {
48  };
49 
50  public:
51 
58  ApplicationLauncher(const char *path, const char **argv);
59 
65  const ProcessID getPid() const;
66 
72  const int getExitCode() const;
73 
79  Result exec();
80 
86  Result terminate() const;
87 
93  Result wait();
94 
95  private:
96 
98  const String m_path;
99 
101  const char **m_argv;
102 
105 
108 };
109 
115 #endif /* __LIB_LIBAPP_APPLICATIONLAUNCHER_H */
ApplicationLauncher::getPid
const ProcessID getPid() const
Retrieve Process Identifier of the program.
Definition: ApplicationLauncher.cpp:37
ApplicationLauncher::terminate
Result terminate() const
Terminate the program.
Definition: ApplicationLauncher.cpp:89
ApplicationLauncher::ApplicationLauncher
ApplicationLauncher(const char *path, const char **argv)
Constructor.
Definition: ApplicationLauncher.cpp:28
ApplicationLauncher::m_path
const String m_path
Absolute path to the program to run.
Definition: ApplicationLauncher.h:98
Types.h
ApplicationLauncher::m_argv
const char ** m_argv
Array with pointers to program arguments.
Definition: ApplicationLauncher.h:101
String
Abstraction of strings.
Definition: String.h:41
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
ApplicationLauncher::IOError
@ IOError
Definition: ApplicationLauncher.h:47
ApplicationLauncher::wait
Result wait()
Wait for the program to terminate.
Definition: ApplicationLauncher.cpp:106
ApplicationLauncher::Result
Result
Result code.
Definition: ApplicationLauncher.h:42
ApplicationLauncher::NotFound
@ NotFound
Definition: ApplicationLauncher.h:46
ApplicationLauncher::exec
Result exec()
Runs the external program.
Definition: ApplicationLauncher.cpp:47
ApplicationLauncher::m_pid
ProcessID m_pid
PID of the DatastoreServer.
Definition: ApplicationLauncher.h:104
ApplicationLauncher::getExitCode
const int getExitCode() const
Retrieve exit code of the program.
Definition: ApplicationLauncher.cpp:42
ApplicationLauncher
Helper class to launch an external program.
Definition: ApplicationLauncher.h:35
String.h
ApplicationLauncher::InvalidArgument
@ InvalidArgument
Definition: ApplicationLauncher.h:45
ApplicationLauncher::Success
@ Success
Definition: ApplicationLauncher.h:44
ApplicationLauncher::m_exitCode
int m_exitCode
Exit code after the program has terminated.
Definition: ApplicationLauncher.h:107