quick fix of errors in filter.c/filter.h
[lttv.git] / ltt / branches / poly / lttv / lttv / filter.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
48f6f3c2 19#ifndef FILTER_H
20#define FILTER_H
21
31452f49 22#include <lttv/traceset.h>
a4c292d4 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
31452f49 30
48f6f3c2 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
1a7fa682 55extern GQuark
0769c82f 56 LTTV_FILTER_TRACE,
57 LTTV_FILTER_TRACESET,
58 LTTV_FILTER_TRACEFILE,
59 LTTV_FILTER_STATE,
60 LTTV_FILTER_EVENT;
61
84a333d6 62/**
63 * @enum lttv_expression_op
64 */
65typedef enum _lttv_expression_op
66{
67 LTTV_FIELD_EQ, /** equal */
68 LTTV_FIELD_NE, /** not equal */
69 LTTV_FIELD_LT, /** lower than */
70 LTTV_FIELD_LE, /** lower or equal */
71 LTTV_FIELD_GT, /** greater than */
72 LTTV_FIELD_GE /** greater or equal */
73} lttv_expression_op;
74
75typedef enum _lttv_expression_type
76{
77 LTTV_EXPRESSION,
78 LTTV_SIMPLE_EXPRESSION
79} lttv_expression_type;
80
81typedef struct _lttv_simple_expression
82{
83 lttv_expression_op op;
84 char *field_name;
85 char *value;
86} lttv_simple_expression;
87
1a7fa682 88typedef enum _lttv_logical_op {
89 OR = 1,
90 AND = 1<<1,
91 NOT = 1<<2,
92 XOR = 1<<3
93} lttv_logical_op;
94
a4c292d4 95/*
1a7fa682 96 * Ah .. that's my tree
97 */
84a333d6 98typedef struct _lttv_expression
99{
1a7fa682 100// gboolean or;
101// gboolean not;
102// gboolean and;
103// gboolean xor;
104// gboolean simple_expression;
105 lttv_logical_op op;
106 lttv_expression_type type;
107 union {
108 struct lttv_expression *e;
341aa948 109 // lttv_field_relation *se; /* --> simple expression */
1a7fa682 110 } e;
a4c292d4 111} lttv_expression;
1a7fa682 112
a4c292d4 113
341aa948 114//typedef union _lttv_expression {
115// lttv_simple_expression se;
116//
117//} lttv_expression;
84a333d6 118
119typedef struct _lttv_filter_tree {
120 lttv_expression* node;
121 struct lttv_filter_tree* r_child;
122 struct lttv_filter_tree* l_child;
123} lttv_filter_tree;
124
31452f49 125/**
126 * @struct lttv_filter
127 * ( will later contain a binary tree of filtering options )
128 */
84a333d6 129typedef struct _lttv_filter {
130 lttv_filter_tree* tree;
131} lttv_filter;
132
0769c82f 133gboolean parse_field_path(GList* fp);
134
84a333d6 135gboolean parse_simple_expression(GString* expression);
48f6f3c2 136
48f6f3c2 137/* Compile the filter expression into an efficient data structure */
a4c292d4 138lttv_filter *lttv_filter_new(char *expression, LttvTraceState *tfs);
48f6f3c2 139
140
141/* Check if the tracefile or event satisfies the filter. The arguments are
142 declared as void * to allow these functions to be used as hooks. */
143
0769c82f 144gboolean lttv_filter_tracefile(lttv_filter *filter, LttTracefile *tracefile);
48f6f3c2 145
1a7fa682 146gboolean lttv_filter_tracestate(lttv_filter *filter, LttvTraceState *tracestate);
147
a4c292d4 148gboolean lttv_filter_event(lttv_filter *filter, LttEvent *event);
48f6f3c2 149
150#endif // FILTER_H
151
This page took 0.036898 seconds and 4 git commands to generate.