LinuxStarter.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * 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, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXCore::core
19 * @author Nicola Miskowiec
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25
26#pragma once
27
30#include "ApplicationStarter.h"
31
33{
34 /**
35 * @class LinuxStarter
36 * @ingroup exec
37 * @brief Starts applications in Linux. Shouldn't be used in any other OS, due to system calls being used.
38 * Applications started this way will still run, even when the main application dies.
39 * Can also be used to request the status of an application.
40 */
42 {
43 public:
44 /**
45 * Starts an application. Forks, creates a daemon and starts the executable.
46 * @param application application to be started
47 */
49 StatusManager statusManager,
50 const std::string& commandLineParameters = "",
51 bool printOnly = false) override;
52 virtual void startScenario(Data_Structure::ScenarioPtr scenario,
53 StatusManager statusManager,
54 const std::string& commandLineParameters = "",
55 bool printOnly = false) override;
56
57
58 /**
59 * Returns the status of an application.
60 * @param application application whose status is returned
61 * @return status of the application
62 */
63 virtual std::string getStatus(Data_Structure::ApplicationInstancePtr application,
64 StatusManager statusManager) override;
65
66 private:
67 std::future<void> startApplicationAsync(Data_Structure::ApplicationInstancePtr application,
68 StatusManager statusManager,
69 const std::string& commandLineParameters = "",
70 bool printOnly = false);
71
72 /**
73 * @brief getSystemAppName returns either the Process name of the application with the given pid, or an empty string if there is no such application
74 * @param application
75 * @return
76 */
77 std::string getSystemAppName(Data_Structure::ApplicationInstancePtr application);
78
79 /**
80 * @brief getSystemAppStatus returns an SystemStatus of the given application Possible states are ["Running", "Zombie"] if there is no app status it returns "Stopped"
81 * @param application
82 * @return
83 */
84 std::string getSystemAppStatus(Data_Structure::ApplicationInstancePtr application);
85 };
86
87} // namespace ScenarioManager::Exec
Starts applications in Linux.
virtual std::string getStatus(Data_Structure::ApplicationInstancePtr application, StatusManager statusManager) override
Returns the status of an application.
virtual void startScenario(Data_Structure::ScenarioPtr scenario, StatusManager statusManager, const std::string &commandLineParameters="", bool printOnly=false) override
virtual void startApplication(Data_Structure::ApplicationInstancePtr application, StatusManager statusManager, const std::string &commandLineParameters="", bool printOnly=false) override
Starts an application.
std::shared_ptr< Scenario > ScenarioPtr
Definition Scenario.h:35
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr