NRP Core  1.4.1
launch_command.h
Go to the documentation of this file.
1 /* * NRP Core - Backend infrastructure to synchronize simulations
2  *
3  * Copyright 2020-2023 NRP Team
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * This project has received funding from the European Union’s Horizon 2020
18  * Framework Programme for Research and Innovation under the Specific Grant
19  * Agreement No. 945539 (Human Brain Project SGA3).
20  */
21 
22 #ifndef LAUNCH_COMMAND_H
23 #define LAUNCH_COMMAND_H
24 
27 #include <nlohmann/json.hpp>
28 
29 #include <string>
30 #include <vector>
31 
33  : public PtrTemplates<LaunchCommandInterface>
34 {
35  public:
40  {
41  UNKNOWN = -1,
44  };
45 
46  LaunchCommandInterface() = default;
47  virtual ~LaunchCommandInterface() = default;
48 
62  virtual pid_t launchProcess(const nlohmann::json &launcherConfig, const std::string& procCmd,
63  const std::vector<std::string> &envParams,
64  const std::vector<std::string> &startParams,
65  bool appendParentEnv = true, int logFD = -1) = 0;
66 
72  virtual pid_t stopProcess(unsigned int killWait) = 0;
73 
79  { return UNKNOWN; }
80 
84  virtual std::string_view launchType() const = 0;
85 
86 };
87 
92 template<const char* LAUNCH_COMMAND>
94  : public LaunchCommandInterface
95 {
96  public:
97  static constexpr auto LaunchType = LAUNCH_COMMAND;
98 
99  std::string_view launchType() const override final
100  { return LaunchType; }
101 };
102 
103 
104 #endif // LAUNCH_COMMAND_H
fixed_string.h
LaunchCommandInterface::stopProcess
virtual pid_t stopProcess(unsigned int killWait)=0
Stop a running engine process.
LaunchCommandInterface::getProcessStatus
virtual ENGINE_RUNNING_STATUS getProcessStatus()
Get the current engine process status. If status cannot be retrieved, return ENGINE_RUNNING_STATUS::U...
Definition: launch_command.h:78
LaunchCommandInterface::UNKNOWN
@ UNKNOWN
Definition: launch_command.h:41
LaunchCommandInterface::launchProcess
virtual pid_t launchProcess(const nlohmann::json &launcherConfig, const std::string &procCmd, const std::vector< std::string > &envParams, const std::vector< std::string > &startParams, bool appendParentEnv=true, int logFD=-1)=0
Fork a new process for the given engine. Will read environment variables and start params from engine...
LaunchCommandInterface::LaunchCommandInterface
LaunchCommandInterface()=default
LaunchCommand::LaunchType
static constexpr auto LaunchType
Definition: launch_command.h:97
LaunchCommandInterface
Definition: launch_command.h:32
PtrTemplates
Definition: ptr_templates.h:28
LaunchCommand
Class for launch commands. Must be specialized further.
Definition: launch_command.h:93
ptr_templates.h
LaunchCommandInterface::RUNNING
@ RUNNING
Definition: launch_command.h:42
LaunchCommand::launchType
std::string_view launchType() const override final
Get launch command type.
Definition: launch_command.h:99
LaunchCommandInterface::~LaunchCommandInterface
virtual ~LaunchCommandInterface()=default
LaunchCommandInterface::ENGINE_RUNNING_STATUS
ENGINE_RUNNING_STATUS
Engine Process status.
Definition: launch_command.h:39
LAUNCH_COMMAND
const char LAUNCH_COMMAND[]
Definition: basic_fork.h:28
LaunchCommandInterface::STOPPED
@ STOPPED
Definition: launch_command.h:43
LaunchCommandInterface::launchType
virtual std::string_view launchType() const =0
Get launch command type.
json
nlohmann::json json
Definition: engine_json_server.cpp:31