2023-08-28 12:31:18 +02:00
|
|
|
/* Common entry point for all villas command line tools.
|
2019-04-19 14:51:45 +02:00
|
|
|
*
|
2023-08-31 11:17:07 +02:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-08-28 12:31:18 +02:00
|
|
|
*/
|
2019-04-19 14:51:45 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <villas/colors.hpp>
|
2021-08-11 12:40:19 -04:00
|
|
|
#include <villas/config.hpp>
|
2019-04-19 14:51:45 +02:00
|
|
|
#include <villas/exceptions.hpp>
|
2023-09-07 13:19:19 +02:00
|
|
|
#include <villas/log.hpp>
|
2019-04-19 14:51:45 +02:00
|
|
|
#include <villas/utils.hpp>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
|
|
|
|
class Tool {
|
|
|
|
|
|
|
|
protected:
|
2023-09-07 13:19:19 +02:00
|
|
|
Logger logger;
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
std::string name;
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
static Tool *current_tool;
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
static void staticHandler(int signal, siginfo_t *sinfo, void *ctx);
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
virtual void handler(int, siginfo_t *, void *) {}
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
std::list<int> handlerSignals;
|
2019-06-30 14:34:01 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
static void printCopyright();
|
2023-04-03 10:00:02 +00:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
static void printVersion();
|
2019-04-19 14:51:45 +02:00
|
|
|
|
|
|
|
public:
|
2023-09-07 13:19:19 +02:00
|
|
|
Tool(int ac, char *av[], const std::string &name,
|
|
|
|
const std::list<int> &sigs = {});
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
virtual int main() { return 0; }
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
virtual void usage() {}
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
virtual void parse() {}
|
2019-04-19 14:51:45 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
virtual int run();
|
2019-04-19 14:51:45 +02:00
|
|
|
};
|
|
|
|
|
2022-12-02 17:16:44 +01:00
|
|
|
} // namespace villas
|