work on core filter
[lttv.git] / ltt / branches / poly / lttv / lttv / filter.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 FILTER_H
20 #define FILTER_H
21
22 #include <lttv/traceset.h>
23 #include <lttv/tracecontext.h>
24 #include <lttv/state.h>
25 #include <ltt/ltt.h>
26 #include <ltt/event.h>
27
28 #define AVERAGE_EXPRESSION_LENGTH 6
29 #define MAX_FACTOR 1.5
30
31 /* A filter expression consists in nested AND, OR and NOT expressions
32 involving boolean relation (>, >=, =, !=, <, <=) between event fields and
33 specific values. It is compiled into an efficient data structure which
34 is used in functions to check if a given event or tracefile satisfies the
35 filter.
36
37 The grammar for filters is:
38
39 filter = expression
40
41 expression = "(" expression ")" | "!" expression |
42 expression "&&" expression | expression "||" expression |
43 simpleExpression
44
45 simpleExpression = fieldPath op value
46
47 fieldPath = fieldComponent [ "." fieldPath ]
48
49 fieldComponent = name [ "[" integer "]" ]
50
51 value = integer | double | string
52
53 */
54
55 /**
56 * @enum lttv_expression_op
57 */
58 typedef enum _lttv_expression_op
59 {
60 LTTV_FIELD_EQ, /** equal */
61 LTTV_FIELD_NE, /** not equal */
62 LTTV_FIELD_LT, /** lower than */
63 LTTV_FIELD_LE, /** lower or equal */
64 LTTV_FIELD_GT, /** greater than */
65 LTTV_FIELD_GE /** greater or equal */
66 } lttv_expression_op;
67
68 typedef enum _lttv_expression_type
69 {
70 LTTV_EXPRESSION,
71 LTTV_SIMPLE_EXPRESSION
72 } lttv_expression_type;
73
74 typedef struct _lttv_simple_expression
75 {
76 lttv_expression_op op;
77 char *field_name;
78 char *value;
79 } lttv_simple_expression;
80
81
82 //typedef union _tmp {
83 // struct lttv_expression *e;
84 // lttv_field_relation *se;
85 //} tmp;
86 /*
87 typedef struct _lttv_expression
88 {
89 gboolean or;
90 gboolean not;
91 gboolean and;
92 gboolean xor;
93 gboolean simple_expression;
94 // tmp e;
95 } lttv_expression;
96 */
97
98 typedef union _lttv_expression {
99 lttv_simple_expression se;
100
101 } lttv_expression;
102
103 typedef struct _lttv_filter_tree {
104 lttv_expression* node;
105 struct lttv_filter_tree* r_child;
106 struct lttv_filter_tree* l_child;
107 } lttv_filter_tree;
108
109 /**
110 * @struct lttv_filter
111 * ( will later contain a binary tree of filtering options )
112 */
113 typedef struct _lttv_filter {
114 lttv_filter_tree* tree;
115 } lttv_filter;
116
117 gboolean parse_simple_expression(GString* expression);
118
119 /* Compile the filter expression into an efficient data structure */
120
121 lttv_filter *lttv_filter_new(char *expression, LttvTraceState *tfs);
122
123
124 /* Check if the tracefile or event satisfies the filter. The arguments are
125 declared as void * to allow these functions to be used as hooks. */
126
127 gboolean lttv_filter_tracefile(lttv_filter *filter, LttvTrace *tracefile);
128
129 gboolean lttv_filter_event(lttv_filter *filter, LttEvent *event);
130
131 #endif // FILTER_H
132
This page took 0.032522 seconds and 4 git commands to generate.