PandA-2024.02
ToolManager.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
44 #ifndef _TOOL_MANAGER_HPP_
45 #define _TOOL_MANAGER_HPP_
46 
47 #include "refcount.hpp"
49 
50 #include <string>
51 #include <vector>
52 
54 {
55  protected:
58 
60  std::string executable;
61 
63  std::string setup_script;
64 
66  bool local;
67 
69  std::string host;
71  std::string remote_path;
72 
75 
81  int execute_command(const std::string& _command_, const std::string& error_message, const std::string& log_file,
82  bool permissive = false, bool throw_message = true);
83 
87  int check_command(const std::string& _tool_, const std::string& setupscr, const std::string& _host_,
88  bool permissive = false);
92  std::string create_remote_command_line(const std::vector<std::string>& parameters) const;
93 
98  void prepare_input_files(const std::vector<std::string>& files);
99 
104  void check_output_files(const std::vector<std::string>& files);
105 
110  std::string create_command_line(const std::vector<std::string>& parameters) const;
111 
115  void remove_files(const std::vector<std::string>& input_files, const std::vector<std::string>& files);
116 
117  public:
122  explicit ToolManager(const ParameterConstRef& Param);
123 
127  virtual ~ToolManager();
128 
132  void configure(const std::string& _tool_, const std::string& setupscr, const std::string& _host_ = "",
133  const std::string& _remote_path_ = "", bool force_remote = false);
134 
142  int execute(const std::vector<std::string>& parameters, const std::vector<std::string>& input_files,
143  const std::vector<std::string>& output_files = std::vector<std::string>(),
144  const std::string& log_file = std::string(), bool permissive = false);
145 
149  std::vector<std::string> determine_paths(std::vector<std::string>& files, bool overwrite = true);
150 
151  std::string determine_paths(std::string& file_name, bool overwrite = true);
152 };
153 
156 
157 #endif
std::string create_remote_command_line(const std::vector< std::string > &parameters) const
Generate the command to the executed on the remote host.
void check_output_files(const std::vector< std::string > &files)
Check that the output files have been correctly generated.
std::string host
this string represent the host machine if remote
Definition: ToolManager.hpp:69
bool local
flag to specify if the executable is local (true) or remote (false)
Definition: ToolManager.hpp:66
void prepare_input_files(const std::vector< std::string > &files)
Check that the input files exist.
std::string remote_path
it represents the paths on the host where the files have to be copied
Definition: ToolManager.hpp:71
void configure(const std::string &_tool_, const std::string &setupscr, const std::string &_host_="", const std::string &_remote_path_="", bool force_remote=false)
Configuration of the tool.
const ParameterConstRef Param
The set of parameters passed to the tool.
Definition: ToolManager.hpp:57
std::vector< std::string > determine_paths(std::vector< std::string > &files, bool overwrite=true)
Determine the relative paths of the inputs files.
ToolManager(const ParameterConstRef &Param)
Constructor.
Definition: ToolManager.cpp:57
virtual ~ToolManager()
Destructor.
Definition: ToolManager.cpp:63
void remove_files(const std::vector< std::string > &input_files, const std::vector< std::string > &files)
Removed the specified files.
Template definition of refcount.
int execute_command(const std::string &_command_, const std::string &error_message, const std::string &log_file, bool permissive=false, bool throw_message=true)
Execute the command and check the return code.
Definition: ToolManager.cpp:71
int check_command(const std::string &_tool_, const std::string &setupscr, const std::string &_host_, bool permissive=false)
Check if a command exist on a given host provided a configuration script.
CONSTREF_FORWARD_DECL(Parameter)
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
std::string create_command_line(const std::vector< std::string > &parameters) const
Simply creates the command line starting from the list of parameters.
std::string executable
this string represent the path of the executable
Definition: ToolManager.hpp:60
int debug_level
debug level of the class
Definition: ToolManager.hpp:74
int execute(const std::vector< std::string > &parameters, const std::vector< std::string > &input_files, const std::vector< std::string > &output_files=std::vector< std::string >(), const std::string &log_file=std::string(), bool permissive=false)
Execute the tool.
std::string setup_script
this string has the script used to setup the environment for the executable
Definition: ToolManager.hpp:63

Generated on Mon Feb 12 2024 13:02:56 for PandA-2024.02 by doxygen 1.8.13