+/*! \file lttv/lttv/filter.h
+ * \brief Defines the core filter of application
+ *
+ * A filter expression consists in nested AND, OR and NOT expressions
+ * involving boolean relation (>, >=, =, !=, <, <=) between event fields and
+ * specific values. It is compiled into an efficient data structure which
+ * is used in functions to check if a given event or tracefile satisfies the
+ * filter.
+ *
+ * The grammar for filters is:
+ *
+ * filter = expression
+ *
+ * expression = "(" expression ")" | "!" expression |
+ * expression "&&" expression | expression "||" expression |
+ * simpleExpression
+ *
+ * simpleExpression = fieldPath op value
+ *
+ * fieldPath = fieldComponent [ "." fieldPath ]
+ *
+ * fieldComponent = name [ "[" integer "]" ]
+ *
+ * value = integer | double | string
+ */
+
+
+#include <lttv/traceset.h>
+#include <lttv/tracecontext.h>
+#include <lttv/state.h>
+#include <lttv/module.h>
+#include <ltt/ltt.h>
+#include <ltt/time.h>
+#include <ltt/event.h>
+
+/* structures prototypes */
+typedef enum _LttvStructType LttvStructType;
+typedef enum _LttvFieldType LttvFieldType;
+typedef enum _LttvExpressionOp LttvExpressionOp;
+typedef enum _LttvTreeElement LttvTreeElement;
+typedef enum _LttvLogicalOp LttvLogicalOp;
+
+typedef union _LttvFieldValue LttvFieldValue;
+
+typedef struct _LttvSimpleExpression LttvSimpleExpression;
+typedef struct _LttvFilterTree LttvFilterTree;
+
+#ifndef LTTVFILTER_TYPE_DEFINED
+typedef struct _LttvFilter LttvFilter;
+#define LTTVFILTER_TYPE_DEFINED
+#endif
+
+/**
+ * @enum _LttvStructType
+ * @brief The lttv structures
+ *
+ * the LttvStructType enumerates
+ * the possible structures for the
+ * lttv core filter
+ */
+enum _LttvStructType {
+ LTTV_FILTER_TRACE, /**< trace (LttTrace) */
+ LTTV_FILTER_TRACESET, /**< traceset */
+ LTTV_FILTER_TRACEFILE, /**< tracefile (LttTracefile) */
+ LTTV_FILTER_EVENT, /**< event (LttEvent) */
+ LTTV_FILTER_STATE /**< state (LttvProcessState) */
+};
+
+/**
+ * @enum _LttvFieldType
+ * @brief Possible fields for the structures
+ *
+ * the LttvFieldType enum consists on
+ * all the hardcoded structures and
+ * their appropriate fields on which
+ * filters can be applied.
+ */
+enum _LttvFieldType {
+ LTTV_FILTER_TRACE_NAME, /**< trace.name (char*) */
+ LTTV_FILTER_TRACEFILE_NAME, /**< tracefile.name (char*) */
+ LTTV_FILTER_STATE_PID, /**< state.pid (guint) */
+ LTTV_FILTER_STATE_PPID, /**< state.ppid (guint) */
+ LTTV_FILTER_STATE_CT, /**< state.creation_time (double) */
+ LTTV_FILTER_STATE_IT, /**< state.insertion_time (double) */
+ LTTV_FILTER_STATE_P_NAME, /**< state.process_name (char*) */
+ LTTV_FILTER_STATE_EX_MODE, /**< state.execution_mode (LttvExecutionMode) */
+ LTTV_FILTER_STATE_EX_SUBMODE, /**< state.execution_submode (LttvExecutionSubmode) */
+ LTTV_FILTER_STATE_P_STATUS, /**< state.process_status (LttvProcessStatus) */
+ LTTV_FILTER_STATE_CPU, /**< state.cpu (?last_cpu?) */
+ LTTV_FILTER_EVENT_NAME, /**< event.name (char*) */
+ LTTV_FILTER_EVENT_FACILITY, /**< event.facility (char*) */
+ LTTV_FILTER_EVENT_CATEGORY, /**< FIXME: not implemented */
+ LTTV_FILTER_EVENT_TIME, /**< event.time (double) */
+ LTTV_FILTER_EVENT_TSC, /**< event.tsc (double) */
+ LTTV_FILTER_EVENT_FIELD, /**< dynamic field, specified in core.xml */
+ LTTV_FILTER_UNDEFINED /**< undefined field */
+};
+
+/**
+ * @enum _LttvExpressionOp
+ * @brief Contains possible operators
+ *
+ * This enumeration defines the
+ * possible operator used to compare
+ * right and left member in simple
+ * expression
+ */
+enum _LttvExpressionOp
+{
+ LTTV_FIELD_EQ, /**< equal */
+ LTTV_FIELD_NE, /**< not equal */
+ LTTV_FIELD_LT, /**< lower than */
+ LTTV_FIELD_LE, /**< lower or equal */
+ LTTV_FIELD_GT, /**< greater than */
+ LTTV_FIELD_GE /**< greater or equal */
+};
+
+/**
+ * @union _LttvFieldValue
+ * @brief Contains possible field values
+ *
+ * This particular union defines the
+ * possible set of values taken by the
+ * right member of a simple expression.
+ * It is used for comparison whithin the
+ * 'operators' functions
+ */
+union _LttvFieldValue {
+ guint64 v_uint64; /**< unsigned int of 64 bytes */
+ guint32 v_uint32; /**< unsigned int of 32 bytes */
+ guint16 v_uint16; /**< unsigned int of 16 bytes */
+ guint16 v_uint; /**< unsigned int */
+ double v_double; /**< double */
+ char* v_string; /**< string */
+ LttTime v_ltttime; /**< LttTime */
+};
+
+/**
+ * @enum _LttvTreeElement
+ * @brief element types for the tree nodes
+ *
+ * LttvTreeElement defines the possible
+ * types of nodes which build the LttvFilterTree.
+ */
+enum _LttvTreeElement {
+ LTTV_TREE_IDLE, /**< this node does nothing */
+ LTTV_TREE_NODE, /**< this node contains a logical operator */
+ LTTV_TREE_LEAF /**< this node is a leaf and contains a simple expression */
+};