1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc. 2 Contributed by Oracle. 3 4 This file is part of GNU Binutils. 5 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. 10 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. 15 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. */ 20 21 #ifndef _METRIC_H 22 #define _METRIC_H 23 24 #include "dbe_structs.h" 25 #include "vec.h" 26 #include "enums.h" 27 #include "BaseMetric.h" 28 29 #define MAX_LEN 1024 30 31 class Expression; 32 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 36 { 37 public: 38 39 typedef struct HistMetricS 40 { 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; 52 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 (); 57 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); 62 63 // fetch various fields from a Metric 64 SubType get_subtype()65 get_subtype () 66 { 67 return subtype; 68 } 69 70 char * get_name()71 get_name () 72 { 73 return name; 74 } 75 76 char * get_abbr()77 get_abbr () 78 { 79 return abbr; 80 } 81 82 char * get_abbr_unit()83 get_abbr_unit () 84 { 85 return abbr_unit; 86 } 87 88 BaseMetric * get_base_metric()89 get_base_metric () 90 { 91 return baseMetric; 92 } 93 94 int get_visbits()95 get_visbits () 96 { 97 return visbits; 98 } 99 100 void set_raw_visbits(int _visbits)101 set_raw_visbits (int _visbits) 102 { 103 visbits = _visbits; 104 } 105 106 void clear_all_visbits()107 clear_all_visbits () 108 { 109 visbits = VAL_NA; 110 } 111 112 void enable_all_visbits()113 enable_all_visbits () 114 { 115 visbits = get_value_styles (); 116 } 117 118 119 #define VAL_IS_HIDDEN(n) ((n) == -1 || (n) == VAL_NA || ((n) & VAL_HIDE_ALL) != 0) 120 121 bool is_any_visible()122 is_any_visible () 123 { 124 return !VAL_IS_HIDDEN (visbits) 125 && (visbits & (VAL_VALUE | VAL_TIMEVAL | VAL_PERCENT)); 126 } 127 128 bool is_value_visible()129 is_value_visible () 130 { 131 return (visbits & VAL_VALUE) != 0 132 || (!is_time_val () && (visbits & VAL_TIMEVAL) != 0); 133 } 134 135 bool is_time_visible()136 is_time_visible () 137 { 138 return is_time_val () && (visbits & VAL_TIMEVAL) != 0; 139 } 140 141 bool is_visible()142 is_visible () 143 { 144 return !VAL_IS_HIDDEN (visbits) && is_value_visible (); 145 } 146 147 bool is_tvisible()148 is_tvisible () 149 { 150 return !VAL_IS_HIDDEN (visbits) && is_time_visible (); 151 } 152 153 bool is_pvisible()154 is_pvisible () 155 { 156 return !VAL_IS_HIDDEN (visbits) && (visbits & VAL_PERCENT) != 0; 157 } 158 159 bool is_time_val()160 is_time_val () 161 { 162 int v = VAL_TIMEVAL | VAL_VALUE; 163 return (get_value_styles () & v) == v; 164 } 165 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); 171 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 (); 177 178 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 186 }; 187 188 #endif /* _METRIC_H */ 189