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 
28 #include "../data_structure/ApplicationInstance.h"
29 #include "ApplicationStarter.h"
30 #include "../parser/StatusManager.h"
31 
32 
33 namespace ScenarioManager::Exec
34 {
35  /**
36  * @class LinuxStarter
37  * @ingroup exec
38  * @brief Starts applications in Linux. Shouldn't be used in any other OS, due to system calls being used.
39  * Applications started this way will still run, even when the main application dies.
40  * Can also be used to request the status of an application.
41  */
43  {
44  public:
45  /**
46  * Starts an application. Forks, creates a daemon and starts the executable.
47  * @param application application to be started
48  */
49  virtual void startApplication(Data_Structure::ApplicationInstancePtr application, StatusManager statusManager, const std::string& commandLineParameters = "", bool printOnly = false) override;
50  virtual void startScenario(Data_Structure::ScenarioPtr scenario, StatusManager statusManager, const std::string& commandLineParameters = "", bool printOnly = false) override;
51 
52 
53  /**
54  * Returns the status of an application.
55  * @param application application whose status is returned
56  * @return status of the application
57  */
58  virtual std::string getStatus(Data_Structure::ApplicationInstancePtr application, StatusManager statusManager) override;
59  private:
60  std::future<void> startApplicationAsync(Data_Structure::ApplicationInstancePtr application, StatusManager statusManager, const std::string& commandLineParameters = "", bool printOnly = false);
61 
62  /**
63  * @brief getSystemAppName returns either the Process name of the application with the given pid, or an empty string if there is no such application
64  * @param application
65  * @return
66  */
67  std::string getSystemAppName(Data_Structure::ApplicationInstancePtr application);
68 
69  /**
70  * @brief getSystemAppStatus returns an SystemStatus of the given application Possible states are ["Running", "Zombie"] if there is no app status it returns "Stopped"
71  * @param application
72  * @return
73  */
74  std::string getSystemAppStatus(Data_Structure::ApplicationInstancePtr application);
75  };
76 
77 }
ScenarioManager::Exec::LinuxStarter::getStatus
virtual std::string getStatus(Data_Structure::ApplicationInstancePtr application, StatusManager statusManager) override
Returns the status of an application.
Definition: LinuxStarter.cpp:240
ScenarioManager::Data_Structure::ApplicationInstancePtr
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr
Definition: ApplicationInstance.h:33
ScenarioManager::Data_Structure::ScenarioPtr
std::shared_ptr< Scenario > ScenarioPtr
Definition: Scenario.h:36
ScenarioManager::Exec
Definition: ApplicationStarter.h:35
ScenarioManager::Exec::LinuxStarter
Starts applications in Linux. Shouldn't be used in any other OS, due to system calls being used....
Definition: LinuxStarter.h:42
ScenarioManager::Exec::ApplicationStarter
Definition: ApplicationStarter.h:43
ScenarioManager::Exec::ApplicationStarter::commandLineParameters
std::string commandLineParameters
Definition: ApplicationStarter.h:61
ScenarioManager::StatusManager
Definition: StatusManager.h:7
ScenarioManager::Exec::LinuxStarter::startApplication
virtual void startApplication(Data_Structure::ApplicationInstancePtr application, StatusManager statusManager, const std::string &commandLineParameters="", bool printOnly=false) override
Starts an application.
Definition: LinuxStarter.cpp:109
ApplicationStarter.h
ScenarioManager::Exec::LinuxStarter::startScenario
virtual void startScenario(Data_Structure::ScenarioPtr scenario, StatusManager statusManager, const std::string &commandLineParameters="", bool printOnly=false) override
Definition: LinuxStarter.cpp:88