Update FSF address
[lttv.git] / lttv / lttv / attribute.h
CommitLineData
9c312311 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
b9ce0bad
YB
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
9c312311 17 */
18
c5d77517 19#ifndef ATTRIBUTE_H
20#define ATTRIBUTE_H
21
c47a6dc6 22/* FIXME : unnamed attributes not implemented */
bcc71139 23
dc877563 24#include <glib-object.h>
25#include <lttv/iattribute.h>
f95bc830 26#include <stdio.h>
c5d77517 27
dc877563 28#define LTTV_ATTRIBUTE_TYPE (lttv_attribute_get_type ())
29#define LTTV_ATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_ATTRIBUTE_TYPE, LttvAttribute))
30#define LTTV_ATTRIBUTE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_ATTRIBUTE_TYPE, LttvAttributeClass))
31#define LTTV_IS_ATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_ATTRIBUTE_TYPE))
32#define LTTV_IS_ATTRIBUTE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_ATTRIBUTE_TYPE))
33#define LTTV_ATTRIBUTE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_ATTRIBUTE_TYPE, LttvAttributeClass))
c5d77517 34
c5d77517 35
dc877563 36typedef struct _LttvAttribute LttvAttribute;
37typedef struct _LttvAttributeClass LttvAttributeClass;
c5d77517 38
dc877563 39struct _LttvAttribute {
90e19f82 40 GObject parent;
c5d77517 41
90e19f82
AM
42 /* private members */
43 GHashTable *names;
44 GArray *attributes;
dc877563 45};
c5d77517 46
dc877563 47struct _LttvAttributeClass {
90e19f82 48 GObjectClass parent;
3e67c985 49
dc877563 50};
c5d77517 51
90e19f82
AM
52GType
53lttv_attribute_get_type (void);
c5d77517 54
c5d77517 55
dc877563 56/* The functions exported in the IAttribute interface are also available
57 directly. */
c5d77517 58
c5d77517 59
dc877563 60/* Total number of attributes */
c5d77517 61
90e19f82
AM
62unsigned int
63lttv_attribute_get_number(LttvAttribute *self);
c5d77517 64
c5d77517 65
dc877563 66/* Container type. Named (fields in struct or elements in a hash table)
67 or unnamed (elements in an array) attributes, homogeneous type or not. */
c5d77517 68
90e19f82
AM
69gboolean
70lttv_attribute_named(LttvAttribute *self, gboolean *homogeneous);
c5d77517 71
72
dc877563 73/* Get the i th attribute along with its type and a pointer to its value. */
c5d77517 74
90e19f82
AM
75LttvAttributeType
76lttv_attribute_get(LttvAttribute *self, unsigned i, LttvAttributeName *name,
77 LttvAttributeValue *v, gboolean *is_named);
dc877563 78
c5d77517 79
dc877563 80/* Get the named attribute in the table along with its type and a pointer to
81 its value. If the named attribute does not exist, the type is LTTV_NONE. */
c5d77517 82
90e19f82
AM
83LttvAttributeType
84lttv_attribute_get_by_name(LttvAttribute *self, LttvAttributeName name,
85 LttvAttributeValue *v);
c5d77517 86
87
dc877563 88/* Add an attribute, which must not exist. The name is an empty string for
89 containers with unnamed attributes. */
c5d77517 90
90e19f82
AM
91LttvAttributeValue
92lttv_attribute_add(LttvAttribute *self, LttvAttributeName name,
93 LttvAttributeType t);
c5d77517 94
90e19f82
AM
95LttvAttributeValue
96lttv_attribute_add_unnamed(LttvAttribute *self, LttvAttributeName name,
97 LttvAttributeType t);
c5d77517 98
dc877563 99/* Remove an attribute */
c5d77517 100
90e19f82
AM
101void
102lttv_attribute_remove(LttvAttribute *self, unsigned i);
c5d77517 103
90e19f82
AM
104void
105lttv_attribute_remove_by_name(LttvAttribute *self, LttvAttributeName name);
c5d77517 106
c5d77517 107
dc877563 108/* Create an empty iattribute object and add it as an attribute under the
109 specified name, or return an existing iattribute attribute. If an
110 attribute of that name already exists but is not a GObject supporting the
111 iattribute interface, return NULL. */
1b82f325 112
90e19f82
AM
113LttvAttribute*
114lttv_attribute_find_subdir(LttvAttribute *self, LttvAttributeName name);
1b82f325 115
90e19f82
AM
116LttvAttribute*
117lttv_attribute_find_subdir_unnamed(LttvAttribute *self, LttvAttributeName name);
c0cb4d12 118
119
90e19f82
AM
120gboolean
121lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
122 LttvAttributeType t, LttvAttributeValue *v);
1b82f325 123
1b82f325 124
b445142a 125/* Free recursively a tree of attributes. All contained gobject of type
126 LttvAttribute are freed (unreferenced) recursively. */
127
c47a6dc6 128// Now done by default.
129// void lttv_attribute_recursive_free(LttvAttribute *self);
b445142a 130
131/* Add items from a tree of attributes to another tree. */
132
90e19f82
AM
133void
134lttv_attribute_recursive_add(LttvAttribute *dest, LttvAttribute *src);
b445142a 135
f95bc830 136void
137lttv_attribute_write_xml(LttvAttribute *self, FILE *fp, int pos, int indent);
138
90e19f82
AM
139void
140lttv_attribute_read_xml(LttvAttribute *self, FILE *fp);
f95bc830 141
c5d77517 142#endif // ATTRIBUTE_H
This page took 0.0817870000000001 seconds and 4 git commands to generate.