mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: give counter values backpointer and time-offset
That way we can do more things when databinding into the UI such as show the counter category/name.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user