| 1 |
/* sysprof-document-ctrdef.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-ctrdef.h" |
| 25 |
|
| 26 |
struct _SysprofDocumentCtrdef |
| 27 |
{ |
| 28 |
SysprofDocumentFrame parent_instance; |
| 29 |
}; |
| 30 |
|
| 31 |
struct _SysprofDocumentCtrdefClass |
| 32 |
{ |
| 33 |
SysprofDocumentFrameClass parent_class; |
| 34 |
}; |
| 35 |
|
| 36 |
G_DEFINE_FINAL_TYPE (SysprofDocumentCtrdef, sysprof_document_ctrdef, SYSPROF_TYPE_DOCUMENT_FRAME) |
| 37 |
|
| 38 |
static void |
| 39 |
sysprof_document_ctrdef_class_init (SysprofDocumentCtrdefClass *klass) |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
static void |
| 44 |
sysprof_document_ctrdef_init (SysprofDocumentCtrdef *self) |
| 45 |
{ |
| 46 |
} |
| 47 |
|
| 48 |
guint |
| 49 |
sysprof_document_ctrdef_get_n_counters (SysprofDocumentCtrdef *self) |
| 50 |
{ |
| 51 |
const SysprofCaptureCounterDefine *ctrdef; |
| 52 |
|
| 53 |
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_CTRDEF (self), 0); |
| 54 |
|
| 55 |
ctrdef = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureCounterDefine); |
| 56 |
|
| 57 |
return SYSPROF_DOCUMENT_FRAME_UINT16 (self, ctrdef->n_counters); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* sysprof_document_ctrdef_get_counter: |
| 62 |
* @self: a #SysprofDocumentCtrdef |
| 63 |
* @nth: a value between 0 and sysprof_document_ctrdef_get_n_counters() |
| 64 |
* @id: (out): a location for the id of the counter |
| 65 |
* @type: (out): a location for either %SYSPROF_CAPTURE_COUNTER_INT64 |
| 66 |
* or %SYSPROF_CAPTURE_COUNTER_DOUBLE |
| 67 |
* @category: (out): a location for the category |
| 68 |
* @name: (out): a location for the name |
| 69 |
* @description: (out): a location for the description |
| 70 |
* |
| 71 |
* Gets information about a counter defined in @self. |
| 72 |
*/ |
| 73 |
void |
| 74 |
sysprof_document_ctrdef_get_counter (SysprofDocumentCtrdef *self, |
| 75 |
guint nth, |
| 76 |
guint *id, |
| 77 |
guint *type, |
| 78 |
const char **category, |
| 79 |
const char **name, |
| 80 |
const char **description) |
| 81 |
{ |
| 82 |
const SysprofCaptureCounterDefine *ctrdef; |
| 83 |
const SysprofCaptureCounter *ctr; |
| 84 |
|
| 85 |
g_return_if_fail (SYSPROF_IS_DOCUMENT_CTRDEF (self)); |
| 86 |
g_return_if_fail (nth < sysprof_document_ctrdef_get_n_counters (self)); |
| 87 |
|
| 88 |
ctrdef = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureCounterDefine); |
| 89 |
ctr = &ctrdef->counters[nth]; |
| 90 |
|
| 91 |
if (id != NULL) |
| 92 |
*id = SYSPROF_DOCUMENT_FRAME_UINT32 (self, ctr->id); |
| 93 |
|
| 94 |
if (type != NULL) |
| 95 |
*type = ctr->type; |
| 96 |
|
| 97 |
if (category != NULL) |
| 98 |
*category = SYSPROF_DOCUMENT_FRAME_CSTRING (self, ctr->category); |
| 99 |
|
| 100 |
if (name != NULL) |
| 101 |
*name = SYSPROF_DOCUMENT_FRAME_CSTRING (self, ctr->name); |
| 102 |
|
| 103 |
if (description != NULL) |
| 104 |
*description = SYSPROF_DOCUMENT_FRAME_CSTRING (self, ctr->description); |
| 105 |
} |