Added Query functions. Major renaming of stuff to use camelcase type names.
[rrq/rrqmisc.git] / vector / Query.h
1 #ifndef query_H
2 #define query_H
3
4 #include <TupleSchema.h>
5 #include <Relation.h>
6
7 struct query_callbacks;
8
9 /**
10  * A query is an implementation of a generic ABI over relations. It's
11  * more or less a "virtual Relation" representing a logical composite
12  * access of actual relations, and as such its active part is held in
13  * a separate \ref querytype record similar to how \ref ItemKeyFun
14  * records define valye types.
15  */
16 typedef struct {
17     struct query_callbacks *def;
18 } query;
19
20 /**
21  * \brief Creates an assignment query.
22  *
23  * \param arity is the assignment tuple arity.
24  *
25  * \param names is the (char*) names to assign.
26  *
27  * \param values is the (void*) values to asign.
28  *
29  * The two tuples must have the same arity for assigning names[i] to
30  * values[i]. This query makes the given names have the given values,
31  * once for each (*next) call following a (*reset) call.
32  *
33  * \related query
34  */
35 extern query *query_assign(int arity,tuple *names,tuple *values);
36
37
38
39 typedef struct {
40     query base;
41     Relation *r;
42     tuple *names;
43     tuple *query;
44 } lookup_query;
45
46 /**
47  * \brief Create a lookup_query record for lookup data in a Relation.
48  */
49 extern query *query_lookup(Relation *r,...);
50
51
52
53 #endif