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