1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
22 * The Application class is the base class for all C++ executables
23 * in the Performance Tools Suite
25 * It determines the directory from which the running binary came,
26 * sets up the I18N catalog, the program name, and initializes
27 * an instance of the Settings class to manage all user preferences
28 * and settings. It also manages usage tracking.
30 * Applications which read experiments are derived from a subclass
31 * named DbeApplication (q.v.)
34 #ifndef _APPLICATION_H
35 #define _APPLICATION_H
37 #include "dbe_types.h"
47 Application (int argc, char *argv[], char *_run_dir = NULL);
48 virtual ~Application ();
49 void set_name (const char *_name);
52 // Control the settings of a progress bar, used for GUI applications
53 // this function also detects cancel requests and returns 1
54 // if yes, 0 otherwise
55 static int set_progress (int percentage, const char *proc_str);
56 static char *get_realpath (const char *_name);
58 // queue for messages (from reading er.rc files, ...)
59 void queue_comment (Emsg *m); // queue for messages
60 Emsg *fetch_comments (void); // fetch the queue of comment messages
61 void delete_comments (void); // delete the queue of comment messages
63 // worker threads (currently used in dbe_stat() for stat() calls)
64 int get_number_of_worker_threads ();
66 char *get_version () { return prog_version; }
67 char *get_name () { return prog_name; }
68 char *get_run_dir () { return run_dir; }
69 Emsgqueue *get_comments_queue () { return commentq; };
72 void set_run_dir (char *fdhome = NULL);
73 typedef int (*ProgressFunc)(int, const char *);
75 // Write a usage message; to be defined in derived class
76 virtual void usage () = 0;
79 // Write a version message; to be defined in derived class
80 void print_version_info ();
82 // Can be overridden in derived class
83 virtual int check_args (int argc, char *argv[]);
86 static void set_progress_func (ProgressFunc func) { progress_func = func; }
95 char *run_dir_with_spaces; // used in case there are spaces
101 void set_ut_email (int argc, char *argv[]);
102 int number_of_worker_threads;
103 static ProgressFunc progress_func;
106 extern Application *theApplication;
108 #endif /* _APPLICATION_H */