diff --git a/src/libsysprof-analyze/sysprof-document-counter-private.h b/src/libsysprof-analyze/sysprof-document-counter-private.h index b76ee679..9995221f 100644 --- a/src/libsysprof-analyze/sysprof-document-counter-private.h +++ b/src/libsysprof-analyze/sysprof-document-counter-private.h @@ -24,12 +24,27 @@ G_BEGIN_DECLS +struct _SysprofDocumentCounter +{ + GObject parent_instance; + GRefString *category; + GRefString *description; + GRefString *name; + GArray *values; + double min_value; + double max_value; + gint64 begin_time; + guint id; + guint type; +}; + SysprofDocumentCounter *_sysprof_document_counter_new (guint id, guint type, GRefString *category, GRefString *name, GRefString *description, - GArray *values); + GArray *values, + gint64 begin_time); void _sysprof_document_counter_calculate_range (SysprofDocumentCounter *self); G_END_DECLS diff --git a/src/libsysprof-analyze/sysprof-document-counter-value-private.h b/src/libsysprof-analyze/sysprof-document-counter-value-private.h index 4ffc7515..7a238588 100644 --- a/src/libsysprof-analyze/sysprof-document-counter-value-private.h +++ b/src/libsysprof-analyze/sysprof-document-counter-value-private.h @@ -26,6 +26,7 @@ G_BEGIN_DECLS SysprofDocumentCounterValue *_sysprof_document_counter_value_new (guint type, - const SysprofDocumentTimedValue *value); + const SysprofDocumentTimedValue *value, + SysprofDocumentCounter *counter); G_END_DECLS diff --git a/src/libsysprof-analyze/sysprof-document-counter-value.c b/src/libsysprof-analyze/sysprof-document-counter-value.c index c374aba9..56dcf701 100644 --- a/src/libsysprof-analyze/sysprof-document-counter-value.c +++ b/src/libsysprof-analyze/sysprof-document-counter-value.c @@ -20,18 +20,22 @@ #include "config.h" +#include "sysprof-document-counter-private.h" #include "sysprof-document-counter-value-private.h" struct _SysprofDocumentCounterValue { GObject parent_instance; + SysprofDocumentCounter *counter; SysprofDocumentTimedValue value; guint type; }; enum { PROP_0, + PROP_COUNTER, PROP_TIME, + PROP_TIME_OFFSET, PROP_VALUE_DOUBLE, PROP_VALUE_INT64, N_PROPS @@ -51,10 +55,18 @@ sysprof_document_counter_value_get_property (GObject *object, switch (prop_id) { + case PROP_COUNTER: + g_value_set_object (value, sysprof_document_counter_value_get_counter (self)); + break; + case PROP_TIME: g_value_set_int64 (value, sysprof_document_counter_value_get_time (self)); break; + case PROP_TIME_OFFSET: + g_value_set_int64 (value, sysprof_document_counter_value_get_time_offset (self)); + break; + case PROP_VALUE_DOUBLE: g_value_set_double (value, sysprof_document_counter_value_get_value_double (self)); break; @@ -75,10 +87,20 @@ sysprof_document_counter_value_class_init (SysprofDocumentCounterValueClass *kla object_class->get_property = sysprof_document_counter_value_get_property; + properties [PROP_COUNTER] = + g_param_spec_object ("counter", NULL, NULL, + SYSPROF_TYPE_DOCUMENT_COUNTER, + (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + properties [PROP_TIME] = g_param_spec_int64 ("time", NULL, NULL, G_MININT64, G_MAXINT64, 0, - (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + properties [PROP_TIME_OFFSET] = + g_param_spec_int64 ("time-offset", NULL, NULL, + G_MININT64, G_MAXINT64, 0, + (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); properties[PROP_VALUE_DOUBLE] = g_param_spec_double ("value-double", NULL, NULL, @@ -100,13 +122,15 @@ sysprof_document_counter_value_init (SysprofDocumentCounterValue *self) SysprofDocumentCounterValue * _sysprof_document_counter_value_new (guint type, - const SysprofDocumentTimedValue *value) + const SysprofDocumentTimedValue *value, + SysprofDocumentCounter *counter) { SysprofDocumentCounterValue *self; self = g_object_new (SYSPROF_TYPE_DOCUMENT_COUNTER_VALUE, NULL); self->type = type; self->value = *value; + self->counter = g_object_ref (counter); return self; } @@ -119,6 +143,14 @@ sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self) return self->value.time; } +gint64 +sysprof_document_counter_value_get_time_offset (SysprofDocumentCounterValue *self) +{ + g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER_VALUE (self), 0); + + return self->value.time - self->counter->begin_time; +} + void sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self, GValue *value) @@ -162,3 +194,17 @@ sysprof_document_counter_value_format (SysprofDocumentCounterValue *self) else return g_strdup_printf ("%ld", self->value.v_int64); } + +/** + * sysprof_document_counter_value_get_counter: + * @self: a #SysprofDocumentCounterValue + * + * Returns: (transfer none): a #SysprofDocumentCounter + */ +SysprofDocumentCounter * +sysprof_document_counter_value_get_counter (SysprofDocumentCounterValue *self) +{ + g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER_VALUE (self), NULL); + + return self->counter; +} diff --git a/src/libsysprof-analyze/sysprof-document-counter-value.h b/src/libsysprof-analyze/sysprof-document-counter-value.h index 6f7cfee4..99c65cd2 100644 --- a/src/libsysprof-analyze/sysprof-document-counter-value.h +++ b/src/libsysprof-analyze/sysprof-document-counter-value.h @@ -24,6 +24,8 @@ #include +#include "sysprof-document-counter.h" + G_BEGIN_DECLS #define SYSPROF_TYPE_DOCUMENT_COUNTER_VALUE (sysprof_document_counter_value_get_type()) @@ -32,16 +34,20 @@ SYSPROF_AVAILABLE_IN_ALL G_DECLARE_FINAL_TYPE (SysprofDocumentCounterValue, sysprof_document_counter_value, SYSPROF, DOCUMENT_COUNTER_VALUE, GObject) SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self); +SysprofDocumentCounter *sysprof_document_counter_value_get_counter (SysprofDocumentCounterValue *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self, - GValue *value); +gint64 sysprof_document_counter_value_get_time (SysprofDocumentCounterValue *self); SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_document_counter_value_get_value_int64 (SysprofDocumentCounterValue *self); +gint64 sysprof_document_counter_value_get_time_offset (SysprofDocumentCounterValue *self); SYSPROF_AVAILABLE_IN_ALL -double sysprof_document_counter_value_get_value_double (SysprofDocumentCounterValue *self); +void sysprof_document_counter_value_get_value (SysprofDocumentCounterValue *self, + GValue *value); SYSPROF_AVAILABLE_IN_ALL -char *sysprof_document_counter_value_format (SysprofDocumentCounterValue *self); +gint64 sysprof_document_counter_value_get_value_int64 (SysprofDocumentCounterValue *self); +SYSPROF_AVAILABLE_IN_ALL +double sysprof_document_counter_value_get_value_double (SysprofDocumentCounterValue *self); +SYSPROF_AVAILABLE_IN_ALL +char *sysprof_document_counter_value_format (SysprofDocumentCounterValue *self); G_END_DECLS diff --git a/src/libsysprof-analyze/sysprof-document-counter.c b/src/libsysprof-analyze/sysprof-document-counter.c index 7f857521..4d5bc32e 100644 --- a/src/libsysprof-analyze/sysprof-document-counter.c +++ b/src/libsysprof-analyze/sysprof-document-counter.c @@ -22,23 +22,10 @@ #include -#include "sysprof-document-counter.h" +#include "sysprof-document-counter-private.h" #include "sysprof-document-counter-value-private.h" #include "sysprof-document-private.h" -struct _SysprofDocumentCounter -{ - GObject parent_instance; - GRefString *category; - GRefString *description; - GRefString *name; - GArray *values; - double min_value; - double max_value; - guint id; - guint type; -}; - enum { PROP_0, PROP_CATEGORY, @@ -75,7 +62,7 @@ sysprof_document_counter_get_item (GListModel *model, value = &g_array_index (self->values, SysprofDocumentTimedValue, position); - return _sysprof_document_counter_value_new (self->type, value); + return _sysprof_document_counter_value_new (self->type, value, self); } static void @@ -204,7 +191,8 @@ _sysprof_document_counter_new (guint id, GRefString *category, GRefString *name, GRefString *description, - GArray *values) + GArray *values, + gint64 begin_time) { SysprofDocumentCounter *self; @@ -215,6 +203,7 @@ _sysprof_document_counter_new (guint id, self->name = name; self->description = description; self->values = values; + self->begin_time = begin_time; return self; } diff --git a/src/libsysprof-analyze/sysprof-document.c b/src/libsysprof-analyze/sysprof-document.c index 59695d13..7b687d7e 100644 --- a/src/libsysprof-analyze/sysprof-document.c +++ b/src/libsysprof-analyze/sysprof-document.c @@ -802,7 +802,8 @@ sysprof_document_load_counters (SysprofDocument *self) sysprof_strings_get (self->strings, category), sysprof_strings_get (self->strings, name), sysprof_strings_get (self->strings, description), - g_steal_pointer (&values))); + g_steal_pointer (&values), + self->time_span.begin_nsec)); } } while (egg_bitset_iter_next (&iter, &i));