[sysprof] libsysprof: add range helper



commit 84f135ecedc32e49e4cdb142ebba1559709cb544
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 20 13:18:33 2019 -0700

    libsysprof: add range helper

 src/libsysprof/sysprof-selection.c | 27 +++++++++++++++++++++++++++
 src/libsysprof/sysprof-selection.h |  7 +++++++
 2 files changed, 34 insertions(+)
---
diff --git a/src/libsysprof/sysprof-selection.c b/src/libsysprof/sysprof-selection.c
index f1d2dd0..332408c 100644
--- a/src/libsysprof/sysprof-selection.c
+++ b/src/libsysprof/sysprof-selection.c
@@ -306,3 +306,30 @@ sysprof_selection_copy (const SysprofSelection *self)
 
   return copy;
 }
+
+guint
+sysprof_selection_get_n_ranges (SysprofSelection *self)
+{
+  g_return_val_if_fail (SYSPROF_IS_SELECTION (self), 0);
+  return self->ranges ? self->ranges->len : 0;
+}
+
+void
+sysprof_selection_get_nth_range (SysprofSelection *self,
+                                 guint             nth,
+                                 gint64           *begin_time,
+                                 gint64           *end_time)
+{
+  Range r = {0};
+
+  g_return_if_fail (SYSPROF_IS_SELECTION (self));
+
+  if (self->ranges && nth < self->ranges->len)
+    r = g_array_index (self->ranges, Range, nth);
+
+  if (begin_time)
+    *begin_time = r.begin;
+
+  if (end_time)
+    *end_time = r.end;
+}
diff --git a/src/libsysprof/sysprof-selection.h b/src/libsysprof/sysprof-selection.h
index f173e86..53141a8 100644
--- a/src/libsysprof/sysprof-selection.h
+++ b/src/libsysprof/sysprof-selection.h
@@ -54,6 +54,13 @@ void              sysprof_selection_unselect_range    (SysprofSelection
                                                        gint64                       begin,
                                                        gint64                       end);
 SYSPROF_AVAILABLE_IN_ALL
+guint             sysprof_selection_get_n_ranges      (SysprofSelection            *self);
+SYSPROF_AVAILABLE_IN_ALL
+void              sysprof_selection_get_nth_range     (SysprofSelection            *self,
+                                                       guint                        nth,
+                                                       gint64                      *begin_time,
+                                                       gint64                      *end_time);
+SYSPROF_AVAILABLE_IN_ALL
 void              sysprof_selection_unselect_all      (SysprofSelection            *self);
 SYSPROF_AVAILABLE_IN_ALL
 void              sysprof_selection_foreach           (SysprofSelection            *self,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]