0414ddb8edc2b419f53ead3211d6b8f711ecb852
[rrq/rrqmisc.git] / vector / QueryCallbacks.h
1 #ifndef QueryCallbacks_H
2 #define QueryCallbacks_H
3
4 enum NextState {
5     /**
6      * This state tells the "next" function that it should capture the
7      * incoming BindingTable state and provide the initial Binding of
8      * a new sucession of bindings.
9      */
10     initial, 
11     /**
12      * This state tells the "next" function that it should update the
13      * bidning table with a subsequent Binding in the current
14      * succession of bindings.
15      */
16     subsequent,
17     /**
18      * This state tells the "next" function that it should just
19      * restore the Binding table to its incoming state.
20      */
21     restore
22 };
23
24 /**
25  * A struct Query_callbacks record defines the callbacks for a
26  * specific Query type.
27  */
28 struct QueryCallbacks {
29     /**
30      * \brief Callback function to reclaim the Query memory for a
31      * given Query.
32      *
33      * \param this is the specific \ref Query concerned.
34      *
35      * Ground queries recalim their own state memory. Composite
36      * queries first propagate the reclaim call to its components, and
37      * thereafter reclaim their local state memory.
38      */
39     void (*reclaim)(Query *this);
40     /**
41      * \brief Callback function to update the Binding table with a
42      * succession of alternative bindings.
43      *
44      * \param this is the specific \ref Query concerned.
45      *
46      * \param bt is the Binding table to set bindings in.
47      *
48      * \param s is the call "sub-command" for the function.
49      *
50      * \returns 1 if a new Binding is provided and 0 otherwise.
51      *
52      * This function is called repeatedly for successively obtaining
53      * the alternative bindings that satisfy the Query. The "initial"
54      * state sub-command tells the function to capture the incoming
55      * BindingTable state so that the function can later restore it
56      * upon the "restore" sub-command. Upon the "initial" command, the
57      * function also sets up the Binding table with its first Binding
58      * alternative. This is followed by a series of "subsequent"
59      * sub-command calls for the function to change the BindingTable
60      * for its succession of Binding alternatives. The function should
61      * return 1 after any successful Binding setup, and return 0 when
62      * it cannot setup any (more) Binding.
63      */
64     int (*next)(Query *this,BindingTable *bt,enum NextState state);
65     /**
66      * This callback function adds its binding names to the
67      * hashvector.
68      */
69     void (*bindings)(Query *this,HashVector *hv);
70 };
71
72
73 #endif