|
12 | 12 | #include<tuple> |
13 | 13 |
|
14 | 14 | #include"tuple_hash.h" |
15 | | -#include"Variable.h" |
| 15 | +#include"variable.h" |
| 16 | +#include"tuple_binding.h" |
16 | 17 |
|
17 | 18 | namespacedatalog |
18 | 19 | { |
19 | 20 |
|
20 | 21 | usingnamespacestd; |
21 | 22 |
|
| 23 | +// High-level API functions |
| 24 | + |
| 25 | +/** |
| 26 | + * @brief create a new variable |
| 27 | + * |
| 28 | + * @tparam T |
| 29 | + * @return Variable<T>* |
| 30 | +*/ |
22 | 31 | template<typename T> |
23 | 32 | Variable<T> *var() |
24 | 33 | { |
25 | 34 | returnnew Variable<T>(); |
26 | 35 | } |
27 | 36 |
|
| 37 | +/** |
| 38 | + * @brief get the value of a variable |
| 39 | + * |
| 40 | + * @tparam T |
| 41 | + * @param t |
| 42 | + * @return T |
| 43 | +*/ |
28 | 44 | template<typename T> |
29 | 45 | Tval(Variable<T> *t) |
30 | 46 | { |
31 | 47 | return t->value(); |
32 | 48 | } |
33 | 49 |
|
| 50 | +/** |
| 51 | + * @brief delete a variable |
| 52 | + * |
| 53 | + * @tparam T |
| 54 | + * @param v |
| 55 | +*/ |
34 | 56 | template<typename T> |
35 | 57 | voiddeleteVar(Variable<T> *v) |
36 | 58 | { |
37 | 59 | delete v; |
38 | 60 | } |
39 | 61 |
|
40 | | -template<typename T> |
41 | | -voidunbind(Variable<T> *t) |
42 | | -{ |
43 | | - t->unbind(); |
44 | | -} |
45 | | - |
46 | | -template<typename T> |
47 | | -voidunbind(const T &t) {} |
48 | | - |
49 | | -template<typename... Ts> |
50 | | -voidunbind(const tuple<Ts...> &tuple) |
51 | | -{ |
52 | | -apply([](auto &&... args) { ((unbind(args), ...)); }, tuple); |
53 | | -} |
| 62 | +// TODO: all functions below here to be refactored into separate files |
54 | 63 |
|
55 | 64 | template<typename T> |
56 | 65 | boolbind(const T &a,const T &b) |
|