18#ifndef __FPSDK_COMMON_APP_HPP__
19#define __FPSDK_COMMON_APP_HPP__
227 " -h, --help -- Print program help screen, and exit\n"
228 " -V, --version -- Print program, version and license information, and exit\n"
229 " -v, --verbose / -q, --quiet\n"
230 " -- Increase / decrease logging verbosity, multiple flags accumulate\n"
231 " -J, --journal -- Use systemd journal logging markers instead of colours\n";
238 std::vector<Option> options_;
261 uint64_t start_m_ = 0;
262 uint64_t start_c_ = 0;
263 uint64_t last_m_ = 0;
264 uint64_t last_c_ = 0;
273 double resident_ = 0.0;
274 double shared_ = 0.0;
std::vector< std::string > argv_
argv[] of program
virtual void PrintHelp()=0
Print the help screen and exit(0)
virtual void PrintVersion()
Print version information.
std::string app_name_
App name.
logging::LoggingParams logging_params_
Logging params.
ProgramOptions(const std::string &app_name, const std::vector< Option > &options)
Constructor.
virtual bool CheckOptions(const std::vector< std::string > &args)
Check options, and handle non-flag arguments.
bool LoadFromArgv(int argc, char **argv)
Load arguments from argv[].
static constexpr const char * COMMON_FLAGS_HELP
Help screen for common options.
virtual bool HandleOption(const Option &option, const std::string &argument)=0
Handle a command-line flag argument.
virtual ~ProgramOptions()
Destructor.
Helper to catch SIGINT (CTRL-c)
bool ShouldAbort()
Check if signal was raised and we should abort.
SigIntHelper(const bool warn=true)
Constructor.
~SigIntHelper()
Destructor.
bool WaitAbort(const uint32_t millis=0)
Wait (block) until signal is raised and we should abort.
SigPipeHelper(const bool warn=false)
Constructor.
bool Raised()
Check if signal was raised.
~SigPipeHelper()
Destructor.
Helper to print a strack trace on SIGSEGV and SIGABRT.
Fixposition SDK: Logging.
void PrintStacktrace()
Prints a stacktrace to stderr.
MemUsage GetMemUsage()
Get memory usage.
double mem_peak_
Peak memory usage [MiB].
void Update()
Update stats.
double mem_curr_
Current memory usage [MiB].
time::Duration uptime_
Time since start.
double cpu_curr_
Current (= average since last call to Update()) CPU usage [%].
double cpu_avg_
Average (since start) CPU usage [%].
double cpu_peak_
Peak CPU usage [%].
const char * name
Long option name (or nullptr, some are reserved, see above)
bool has_argument
True if flag requires an an argument, false if not.
char flag
The flag (some are reserved, see above)
Fixposition SDK: Time utilities.