Updated Spanish translation
[anjuta-git-plugin.git] / plugins / profiler / gprof-call-graph-block-entry.c
blob83ec3f164f24004db2222e58dcb163b4307c43b7
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * gprof-call-graph-block-entry.c
4 * Copyright (C) James Liggett 2006 <jrliggett@cox.net>
5 *
6 * gprof-call-graph-block-entry.c is free software.
7 *
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2, or (at your option) any later version.
12 * plugin.c is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with plugin.c. See the file "COPYING". If not,
19 * write to: The Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "gprof-call-graph-block-entry.h"
26 struct _GProfCallGraphBlockEntryPriv
28 gfloat time_perc; /* Percent of total execution */
29 gfloat self_sec; /* Time spent executing this function */
30 gfloat child_sec; /* Time spent on this function's children */
31 gchar *calls; /* Calls from parents and total */
32 gchar *name; /* Name of the function */
35 static void
36 gprof_call_graph_block_entry_init (GProfCallGraphBlockEntry *self)
38 self->priv = g_new0 (GProfCallGraphBlockEntryPriv, 1);
41 static void
42 gprof_call_graph_block_entry_finalize (GObject *obj)
44 GProfCallGraphBlockEntry *self;
46 self = (GProfCallGraphBlockEntry *) obj;
48 g_free (self->priv->name);
49 g_free (self->priv->calls);
50 g_free (self->priv);
53 static void
54 gprof_call_graph_block_entry_class_init (GProfCallGraphBlockEntryClass *klass)
56 GObjectClass *object_class;
58 object_class = (GObjectClass *) klass;
60 object_class->finalize = gprof_call_graph_block_entry_finalize;
63 GType
64 gprof_call_graph_block_entry_get_type (void)
66 static GType obj_type = 0;
68 if (!obj_type)
70 static const GTypeInfo obj_info =
72 sizeof (GProfCallGraphBlockEntryClass),
73 (GBaseInitFunc) NULL,
74 (GBaseFinalizeFunc) NULL,
75 (GClassInitFunc) gprof_call_graph_block_entry_class_init,
76 (GClassFinalizeFunc) NULL,
77 NULL, /* class_data */
78 sizeof (GProfCallGraphBlockEntry),
79 0, /* n_preallocs */
80 (GInstanceInitFunc) gprof_call_graph_block_entry_init,
81 NULL /* value_table */
83 obj_type = g_type_register_static (G_TYPE_OBJECT,
84 "GProfCallGraphBlockEntry", &obj_info,
85 0);
87 return obj_type;
90 GProfCallGraphBlockEntry *
91 gprof_call_graph_block_primary_entry_new (gchar **fields)
93 GProfCallGraphBlockEntry *entry;
95 entry = g_object_new (GPROF_CALL_GRAPH_BLOCK_ENTRY_TYPE, NULL);
97 entry->priv->time_perc = atof (fields[0]);
98 entry->priv->self_sec = atof (fields[1]);
99 entry->priv->child_sec = atof (fields[2]);
100 entry->priv->calls = g_strdup (fields[3]);
101 entry->priv->name = g_strdup (fields[4]);
103 return entry;
106 GProfCallGraphBlockEntry *
107 gprof_call_graph_block_secondary_entry_new (gchar **fields)
109 GProfCallGraphBlockEntry *entry;
111 entry = g_object_new (GPROF_CALL_GRAPH_BLOCK_ENTRY_TYPE, NULL);
113 entry->priv->time_perc = 0.0f;
114 entry->priv->self_sec = atof (fields[0]);
115 entry->priv->child_sec = atof (fields[1]);
116 entry->priv->calls = g_strdup (fields[2]);
117 entry->priv->name = g_strdup (fields[3]);
119 return entry;
122 void
123 gprof_call_graph_block_entry_free (GProfCallGraphBlockEntry *self)
125 g_object_unref (self);
128 gfloat
129 gprof_call_graph_block_entry_get_time_perc (GProfCallGraphBlockEntry *self)
131 return self->priv->time_perc;
135 gfloat
136 gprof_call_graph_block_entry_get_self_sec (GProfCallGraphBlockEntry *self)
138 return self->priv->self_sec;
141 gfloat
142 gprof_call_graph_block_entry_get_child_sec (GProfCallGraphBlockEntry *self)
144 return self->priv->child_sec;
147 gchar *
148 gprof_call_graph_block_entry_get_calls (GProfCallGraphBlockEntry *self)
150 return self->priv->calls;
153 gchar *
154 gprof_call_graph_block_entry_get_name (GProfCallGraphBlockEntry *self)
156 return self->priv->name;
159 GProfCallGraphBlockEntry *
160 gprof_call_graph_block_entry_get_next (GList *current_iter, GList **next_iter)
162 *next_iter = g_list_next (current_iter);
164 if (*next_iter)
165 return GPROF_CALL_GRAPH_BLOCK_ENTRY ((*next_iter)->data);
166 else
167 return NULL;