Update FSF address
[lttv.git] / lttv / lttv / attribute.h
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
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
17 */
18
19 #ifndef ATTRIBUTE_H
20 #define ATTRIBUTE_H
21
22 /* FIXME : unnamed attributes not implemented */
23
24 #include <glib-object.h>
25 #include <lttv/iattribute.h>
26 #include <stdio.h>
27
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))
34
35
36 typedef struct _LttvAttribute LttvAttribute;
37 typedef struct _LttvAttributeClass LttvAttributeClass;
38
39 struct _LttvAttribute {
40 GObject parent;
41
42 /* private members */
43 GHashTable *names;
44 GArray *attributes;
45 };
46
47 struct _LttvAttributeClass {
48 GObjectClass parent;
49
50 };
51
52 GType
53 lttv_attribute_get_type (void);
54
55
56 /* The functions exported in the IAttribute interface are also available
57 directly. */
58
59
60 /* Total number of attributes */
61
62 unsigned int
63 lttv_attribute_get_number(LttvAttribute *self);
64
65
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. */
68
69 gboolean
70 lttv_attribute_named(LttvAttribute *self, gboolean *homogeneous);
71
72
73 /* Get the i th attribute along with its type and a pointer to its value. */
74
75 LttvAttributeType
76 lttv_attribute_get(LttvAttribute *self, unsigned i, LttvAttributeName *name,
77 LttvAttributeValue *v, gboolean *is_named);
78
79
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. */
82
83 LttvAttributeType
84 lttv_attribute_get_by_name(LttvAttribute *self, LttvAttributeName name,
85 LttvAttributeValue *v);
86
87
88 /* Add an attribute, which must not exist. The name is an empty string for
89 containers with unnamed attributes. */
90
91 LttvAttributeValue
92 lttv_attribute_add(LttvAttribute *self, LttvAttributeName name,
93 LttvAttributeType t);
94
95 LttvAttributeValue
96 lttv_attribute_add_unnamed(LttvAttribute *self, LttvAttributeName name,
97 LttvAttributeType t);
98
99 /* Remove an attribute */
100
101 void
102 lttv_attribute_remove(LttvAttribute *self, unsigned i);
103
104 void
105 lttv_attribute_remove_by_name(LttvAttribute *self, LttvAttributeName name);
106
107
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. */
112
113 LttvAttribute*
114 lttv_attribute_find_subdir(LttvAttribute *self, LttvAttributeName name);
115
116 LttvAttribute*
117 lttv_attribute_find_subdir_unnamed(LttvAttribute *self, LttvAttributeName name);
118
119
120 gboolean
121 lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
122 LttvAttributeType t, LttvAttributeValue *v);
123
124
125 /* Free recursively a tree of attributes. All contained gobject of type
126 LttvAttribute are freed (unreferenced) recursively. */
127
128 // Now done by default.
129 // void lttv_attribute_recursive_free(LttvAttribute *self);
130
131 /* Add items from a tree of attributes to another tree. */
132
133 void
134 lttv_attribute_recursive_add(LttvAttribute *dest, LttvAttribute *src);
135
136 void
137 lttv_attribute_write_xml(LttvAttribute *self, FILE *fp, int pos, int indent);
138
139 void
140 lttv_attribute_read_xml(LttvAttribute *self, FILE *fp);
141
142 #endif // ATTRIBUTE_H
This page took 0.031874 seconds and 4 git commands to generate.