libsysprof-analyze: add key property to counters

this can be handy for filtering.
This commit is contained in:
Christian Hergert
2023-07-14 16:26:53 -07:00
parent 71fdc220dc
commit 7b3b37c28e
2 changed files with 20 additions and 0 deletions

View File

@ -44,6 +44,7 @@ enum {
PROP_CATEGORY,
PROP_DESCRIPTION,
PROP_ID,
PROP_KEY,
PROP_MAX_VALUE,
PROP_MIN_VALUE,
PROP_NAME,
@ -133,6 +134,10 @@ sysprof_document_counter_get_property (GObject *object,
g_value_set_string (value, sysprof_document_counter_get_name (self));
break;
case PROP_KEY:
g_value_take_string (value, sysprof_document_counter_dup_key (self));
break;
case PROP_ID:
g_value_set_uint (value, sysprof_document_counter_get_id (self));
break;
@ -165,6 +170,11 @@ sysprof_document_counter_class_init (SysprofDocumentCounterClass *klass)
NULL,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_KEY] =
g_param_spec_string ("key", NULL, NULL,
NULL,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_NAME] =
g_param_spec_string ("name", NULL, NULL,
NULL,
@ -400,3 +410,11 @@ sysprof_document_counter_get_min_value (SysprofDocumentCounter *self)
return self->min_value;
}
char *
sysprof_document_counter_dup_key (SysprofDocumentCounter *self)
{
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER (self), NULL);
return g_strdup_printf ("%s/%s", self->category, self->name);
}