convert from svn repository: remove tags directory
[lttv.git] / trunk / lttv / 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
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
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 {
40 GObject parent;
c5d77517 41
dc877563 42 /* private members */
43 GHashTable *names;
44 GArray *attributes;
45};
c5d77517 46
dc877563 47struct _LttvAttributeClass {
48 GObjectClass parent;
3e67c985 49
dc877563 50};
c5d77517 51
dc877563 52GType lttv_attribute_get_type (void);
c5d77517 53
c5d77517 54
dc877563 55/* The functions exported in the IAttribute interface are also available
56 directly. */
c5d77517 57
c5d77517 58
dc877563 59/* Total number of attributes */
c5d77517 60
dc877563 61unsigned int lttv_attribute_get_number(LttvAttribute *self);
c5d77517 62
c5d77517 63
dc877563 64/* Container type. Named (fields in struct or elements in a hash table)
65 or unnamed (elements in an array) attributes, homogeneous type or not. */
c5d77517 66
dc877563 67gboolean lttv_attribute_named(LttvAttribute *self, gboolean *homogeneous);
c5d77517 68
69
dc877563 70/* Get the i th attribute along with its type and a pointer to its value. */
c5d77517 71
dc877563 72LttvAttributeType lttv_attribute_get(LttvAttribute *self, unsigned i,
c0cb4d12 73 LttvAttributeName *name, LttvAttributeValue *v, gboolean *is_named);
dc877563 74
c5d77517 75
dc877563 76/* Get the named attribute in the table along with its type and a pointer to
77 its value. If the named attribute does not exist, the type is LTTV_NONE. */
c5d77517 78
dc877563 79LttvAttributeType lttv_attribute_get_by_name(LttvAttribute *self,
80 LttvAttributeName name, LttvAttributeValue *v);
c5d77517 81
82
dc877563 83/* Add an attribute, which must not exist. The name is an empty string for
84 containers with unnamed attributes. */
c5d77517 85
dc877563 86LttvAttributeValue lttv_attribute_add(LttvAttribute *self,
87 LttvAttributeName name, LttvAttributeType t);
c5d77517 88
c0cb4d12 89LttvAttributeValue lttv_attribute_add_unnamed(LttvAttribute *self,
90 LttvAttributeName name, LttvAttributeType t);
c5d77517 91
dc877563 92/* Remove an attribute */
c5d77517 93
dc877563 94void lttv_attribute_remove(LttvAttribute *self, unsigned i);
c5d77517 95
dc877563 96void lttv_attribute_remove_by_name(LttvAttribute *self,
97 LttvAttributeName name);
c5d77517 98
c5d77517 99
dc877563 100/* Create an empty iattribute object and add it as an attribute under the
101 specified name, or return an existing iattribute attribute. If an
102 attribute of that name already exists but is not a GObject supporting the
103 iattribute interface, return NULL. */
1b82f325 104
b445142a 105LttvAttribute* lttv_attribute_find_subdir(LttvAttribute *self,
dc877563 106 LttvAttributeName name);
1b82f325 107
c0cb4d12 108LttvAttribute* lttv_attribute_find_subdir_unnamed(LttvAttribute *self,
109 LttvAttributeName name);
110
111
dc877563 112gboolean lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
113 LttvAttributeType t, LttvAttributeValue *v);
1b82f325 114
1b82f325 115
b445142a 116/* Free recursively a tree of attributes. All contained gobject of type
117 LttvAttribute are freed (unreferenced) recursively. */
118
c47a6dc6 119// Now done by default.
120// void lttv_attribute_recursive_free(LttvAttribute *self);
b445142a 121
122/* Add items from a tree of attributes to another tree. */
123
124void lttv_attribute_recursive_add(LttvAttribute *dest, LttvAttribute *src);
125
f95bc830 126void
127lttv_attribute_write_xml(LttvAttribute *self, FILE *fp, int pos, int indent);
128
129void lttv_attribute_read_xml(LttvAttribute *self, FILE *fp);
130
c5d77517 131#endif // ATTRIBUTE_H
This page took 0.065743 seconds and 4 git commands to generate.