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