File tree Expand file tree Collapse file tree 4 files changed +67
-17
lines changed Expand file tree Collapse file tree 4 files changed +67
-17
lines changed Original file line number Diff line number Diff line change 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
namespace datalog
18
19
{
19
20
20
21
using namespace std ;
21
22
23
+ /* *
24
+ * @brief create a new variable
25
+ *
26
+ * @tparam T
27
+ * @return Variable<T>*
28
+ */
22
29
template <typename T>
23
30
Variable<T> *var ()
24
31
{
25
32
return new Variable<T>();
26
33
}
27
34
35
+ /* *
36
+ * @brief get the value of a variable
37
+ *
38
+ * @tparam T
39
+ * @param
10000
t
40
+ * @return T
41
+ */
28
42
template <typename T>
29
43
T val (Variable<T> *t)
30
44
{
31
45
return t->value ();
32
46
}
33
47
48
+ /* *
49
+ * @brief delete a variable
50
+ *
51
+ * @tparam T
52
+ * @param v
53
+ */
34
54
template <typename T>
35
55
void deleteVar (Variable<T> *v)
36
56
{
37
57
delete v;
38
58
}
39
59
40
- template <typename T>
41
- void unbind (Variable<T> *t)
42
- {
43
- t->unbind ();
44
- }
45
-
46
- template <typename T>
47
- void unbind (const T &t) {}
48
-
49
- template <typename ... Ts>
50
- void unbind (const tuple<Ts...> &tuple)
51
- {
52
- apply ([](auto &&... args) { ((unbind (args), ...)); }, tuple);
53
- }
54
-
55
60
template <typename T>
56
61
bool bind (const T &a, const T &b)
57
62
{
Original file line number Diff line number Diff line change
1
+ #ifndef TUPLES_H
2
+ #define TUPLES_H
3
+
4
+ #include " variable.h"
5
+
6
+ namespace datalog {
7
+
8
+ /* *
9
+ * @brief unbind a variable
10
+ *
11
+ * @tparam T
12
+ * @param t
13
+ */
14
+ template <typename T>
15
+ void unbind (Variable<T> *t)
16
+ {
17
+ t->unbind ();
18
+ }
19
+
20
+ /* *
21
+ * @brief unbind no-operation for types that are not variables
22
+ *
23
+ * @tparam T
24
+ * @param t
25
+ */
26
+ template <typename T>
27
+ void unbind (const T &t) {
28
+ // If t is not a Variable then perform no-op
29
+ }
30
+
31
+ /* *
32
+ * @brief apply unbind to a tuple of variables and values
33
+ *
34
+ * @tparam Ts
35
+ * @param tuple
36
+ */
37
+ template <typename ... Ts>
38
+ void unbind (const tuple<Ts...> &tuple)
39
+ {
40
+ apply ([](auto &&... args) { ((unbind (args), ...)); }, tuple);
41
+ }
42
+
43
+ }
44
+
45
+ #endif // TUPLES_H
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
#include " catch.hpp"
2
- #include " Variable .h"
2
+ #include " variable .h"
3
3
4
4
using namespace datalog ;
5
5
You can’t perform that action at this time.
0 commit comments