Debian Codegraph @

src/libsysprof/sysprof-document-fork.c

raw
1 /* sysprof-document-fork.c
2 *
3 * Copyright 2023 Christian Hergert <[email protected]>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: GPL-3.0-or-later
19 */
20
21 #include "config.h"
22
23 #include "sysprof-document-frame-private.h"
24 #include "sysprof-document-fork.h"
25
26 struct _SysprofDocumentFork
27 {
28 SysprofDocumentFrame parent_instance;
29 };
30
31 struct _SysprofDocumentForkClass
32 {
33 SysprofDocumentFrameClass parent_class;
34 };
35
36 enum {
37 PROP_0,
38 PROP_CHILD_PID,
39 N_PROPS
40 };
41
42 G_DEFINE_FINAL_TYPE (SysprofDocumentFork, sysprof_document_fork, SYSPROF_TYPE_DOCUMENT_FRAME)
43
44 static GParamSpec *properties [N_PROPS];
45
46 static void
47 sysprof_document_fork_get_property (GObject *object,
48 guint prop_id,
49 GValue *value,
50 GParamSpec *pspec)
51 {
52 SysprofDocumentFork *self = SYSPROF_DOCUMENT_FORK (object);
53
54 switch (prop_id)
55 {
56 case PROP_CHILD_PID:
57 g_value_set_int (value, sysprof_document_fork_get_child_pid (self));
58 break;
59
60 default:
61 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
62 }
63 }
64
65 static void
66 sysprof_document_fork_class_init (SysprofDocumentForkClass *klass)
67 {
68 GObjectClass *object_class = G_OBJECT_CLASS (klass);
69
70 object_class->get_property = sysprof_document_fork_get_property;
71
72 properties [PROP_CHILD_PID] =
73 g_param_spec_int ("child-pid", NULL, NULL,
74 G_MININT, G_MAXINT, 0,
75 (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
76
77 g_object_class_install_properties (object_class, N_PROPS, properties);
78 }
79
80 static void
81 sysprof_document_fork_init (SysprofDocumentFork *self)
82 {
83 }
84
85 int
86 sysprof_document_fork_get_child_pid (SysprofDocumentFork *self)
87 {
88 const SysprofCaptureFork *fork;
89
90 g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FORK (self), 0);
91
92 fork = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureFork);
93
94 return SYSPROF_DOCUMENT_FRAME_INT32 (self, fork->child_pid);
95 }