Update year range in gprofng copyright notices
[binutils-gdb.git] / gprofng / src / Metric.h
bloba13c1ac29aea02216e2ed5d8f1de175f8c1defde
1 /* Copyright (C) 2021-2023 Free Software Foundation, Inc.
2 Contributed by Oracle.
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)
9 any later version.
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. */
21 #ifndef _METRIC_H
22 #define _METRIC_H
24 #include "dbe_structs.h"
25 #include "vec.h"
26 #include "enums.h"
27 #include "BaseMetric.h"
29 #define MAX_LEN 1024
31 class Expression;
33 // The metric class defines the metrics that are available. The metrics are
34 // registered when the experiment's log file is read.
35 class Metric : public BaseMetric
37 public:
39 typedef struct HistMetricS
41 int width;
42 int maxvalue_width;
43 int maxtime_width;
44 char legend1[MAX_LEN];
45 char legend2[MAX_LEN];
46 char legend3[MAX_LEN];
47 int indFirstExp; // only for -compare=[delta|ratio]
48 int indTimeVal; // only for HWC time-converted metrics
49 void update_max (struct HistMetricS *hm);
50 void init ();
51 } HistMetric;
53 Metric (const Metric& item); // copy constructor
54 Metric (BaseMetric *item, SubType st);
55 Metric (char *_name, SubType st); // for derived metrics
56 virtual ~Metric ();
58 char *get_mcmd (bool); // e.user, a.total, etc. NOTI18N
59 int get_real_visbits (); // methods for managing visibility
60 ValueTag get_vtype2 (); // takes comparison visbits into account
61 void set_dmetrics_visbits (int _dmetrics_visbits);
63 // fetch various fields from a Metric
64 SubType
65 get_subtype ()
67 return subtype;
70 char *
71 get_name ()
73 return name;
76 char *
77 get_abbr ()
79 return abbr;
82 char *
83 get_abbr_unit ()
85 return abbr_unit;
88 BaseMetric *
89 get_base_metric ()
91 return baseMetric;
94 int
95 get_visbits ()
97 return visbits;
100 void
101 set_raw_visbits (int _visbits)
103 visbits = _visbits;
106 void
107 clear_all_visbits ()
109 visbits = VAL_NA;
112 void
113 enable_all_visbits ()
115 visbits = get_value_styles ();
119 #define VAL_IS_HIDDEN(n) ((n) == -1 || (n) == VAL_NA || ((n) & VAL_HIDE_ALL) != 0)
121 bool
122 is_any_visible ()
124 return !VAL_IS_HIDDEN (visbits)
125 && (visbits & (VAL_VALUE | VAL_TIMEVAL | VAL_PERCENT));
128 bool
129 is_value_visible ()
131 return (visbits & VAL_VALUE) != 0
132 || (!is_time_val () && (visbits & VAL_TIMEVAL) != 0);
135 bool
136 is_time_visible ()
138 return is_time_val () && (visbits & VAL_TIMEVAL) != 0;
141 bool
142 is_visible ()
144 return !VAL_IS_HIDDEN (visbits) && is_value_visible ();
147 bool
148 is_tvisible ()
150 return !VAL_IS_HIDDEN (visbits) && is_time_visible ();
153 bool
154 is_pvisible ()
156 return !VAL_IS_HIDDEN (visbits) && (visbits & VAL_PERCENT) != 0;
159 bool
160 is_time_val ()
162 int v = VAL_TIMEVAL | VAL_VALUE;
163 return (get_value_styles () & v) == v;
166 // per-bit handling of visbits
167 // Note: Forces VAL_HIDE_ALL to zero. Use only on temporary Metric objects.
168 void set_vvisible (bool set);
169 void set_tvisible (bool set);
170 void set_pvisible (bool set);
172 void set_subtype (SubType st);
173 void legend_width (HistMetric *hitem, int gap);
174 char *get_vis_str ();
175 char *get_vis_string (int vis);
176 char *dump ();
179 private:
180 BaseMetric *baseMetric;
181 SubType subtype; // specific variant for this Metric
182 char *name;
183 char *abbr;
184 char *abbr_unit;
185 int visbits; // ValueType, e.g. VAL_VALUE|VAL_TIMEVAL
188 #endif /* _METRIC_H */