Moving files around to get rid of the shared include tree. Some other
[lttv.git] / ltt / branches / poly / 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., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19 #ifndef ATTRIBUTE_H
20 #define ATTRIBUTE_H
21
22 #include <glib-object.h>
23 #include <lttv/iattribute.h>
24 #include <stdio.h>
25
26 #define LTTV_ATTRIBUTE_TYPE (lttv_attribute_get_type ())
27 #define LTTV_ATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_ATTRIBUTE_TYPE, LttvAttribute))
28 #define LTTV_ATTRIBUTE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_ATTRIBUTE_TYPE, LttvAttributeClass))
29 #define LTTV_IS_ATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_ATTRIBUTE_TYPE))
30 #define LTTV_IS_ATTRIBUTE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_ATTRIBUTE_TYPE))
31 #define LTTV_ATTRIBUTE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_ATTRIBUTE_TYPE, LttvAttributeClass))
32
33
34 typedef struct _LttvAttribute LttvAttribute;
35 typedef struct _LttvAttributeClass LttvAttributeClass;
36
37 struct _LttvAttribute {
38 GObject parent;
39
40 /* private members */
41 GHashTable *names;
42 GArray *attributes;
43 };
44
45 struct _LttvAttributeClass {
46 GObjectClass parent;
47 };
48
49 GType lttv_attribute_get_type (void);
50
51
52 /* The functions exported in the IAttribute interface are also available
53 directly. */
54
55
56 /* Total number of attributes */
57
58 unsigned int lttv_attribute_get_number(LttvAttribute *self);
59
60
61 /* Container type. Named (fields in struct or elements in a hash table)
62 or unnamed (elements in an array) attributes, homogeneous type or not. */
63
64 gboolean lttv_attribute_named(LttvAttribute *self, gboolean *homogeneous);
65
66
67 /* Get the i th attribute along with its type and a pointer to its value. */
68
69 LttvAttributeType lttv_attribute_get(LttvAttribute *self, unsigned i,
70 LttvAttributeName *name, LttvAttributeValue *v);
71
72
73 /* Get the named attribute in the table along with its type and a pointer to
74 its value. If the named attribute does not exist, the type is LTTV_NONE. */
75
76 LttvAttributeType lttv_attribute_get_by_name(LttvAttribute *self,
77 LttvAttributeName name, LttvAttributeValue *v);
78
79
80 /* Add an attribute, which must not exist. The name is an empty string for
81 containers with unnamed attributes. */
82
83 LttvAttributeValue lttv_attribute_add(LttvAttribute *self,
84 LttvAttributeName name, LttvAttributeType t);
85
86
87 /* Remove an attribute */
88
89 void lttv_attribute_remove(LttvAttribute *self, unsigned i);
90
91 void lttv_attribute_remove_by_name(LttvAttribute *self,
92 LttvAttributeName name);
93
94
95 /* Create an empty iattribute object and add it as an attribute under the
96 specified name, or return an existing iattribute attribute. If an
97 attribute of that name already exists but is not a GObject supporting the
98 iattribute interface, return NULL. */
99
100 LttvAttribute* lttv_attribute_find_subdir(LttvAttribute *self,
101 LttvAttributeName name);
102
103 gboolean lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
104 LttvAttributeType t, LttvAttributeValue *v);
105
106
107 /* Free recursively a tree of attributes. All contained gobject of type
108 LttvAttribute are freed (unreferenced) recursively. */
109
110 void lttv_attribute_recursive_free(LttvAttribute *self);
111
112 /* Add items from a tree of attributes to another tree. */
113
114 void lttv_attribute_recursive_add(LttvAttribute *dest, LttvAttribute *src);
115
116 void
117 lttv_attribute_write_xml(LttvAttribute *self, FILE *fp, int pos, int indent);
118
119 void lttv_attribute_read_xml(LttvAttribute *self, FILE *fp);
120
121 #endif // ATTRIBUTE_H
This page took 0.031089 seconds and 4 git commands to generate.