upgrade for hashvector ABI changes.
[rrq/rrqmisc.git] / vector / tupleitem.h
index 595666848c34a9f49be0a0158c1385b1991b3979..3917c9bc8b72f3333a3e6cb766dba7ca0e718075 100644 (file)
@@ -10,10 +10,11 @@ typedef void *tuple[];
 
 /**
  * A tupleschema record declares the itemkeyfun functions for tuple
- * items together with applicable arity and domain combinations. The
- * macro \ref TUPLEITEMINIT may be used to initialize particular
- * tupleschema records, which each become tupleitem declaration for
- * its particular arity and parts declarations
+ * items together with applicable arity and domain combinations.
+ * Records are created dynamically via the \ref tupleschema_create
+ * function or the \ref TUPLESCHEMA convenience macro.
+ *
+ * \extends itemkeyfun
  */
 typedef struct {
     /**
@@ -22,7 +23,7 @@ typedef struct {
      * itemkeyfun pointer to be within a tupleschema record so as to
      * provide the handling of the tuple columns.
      */
-    itemkeyfun functions;
+    itemkeyfun base;
 
     /**
      * This is the number of columns in a tuple.
@@ -38,11 +39,15 @@ typedef struct {
 
 /**
  * Create a tuples with given values.
+ *
+ * \related tupleschema
  */
 extern tuple *tuple_create(int arity,...);
 
 /**
  * Create a tuples with given values.
+ *
+ * \related tupleschema
  */
 extern tupleschema *tupleschema_create(int arity,tuple *columns);
 
@@ -50,23 +55,46 @@ extern tupleschema *tupleschema_create(int arity,tuple *columns);
  * Copy the given tupleschema into a new tupleschema with some columns
  * masked. This represents a sub-index type using the unmasked columns
  * for indexing.
+ *
+ * \related tupleschema
  */
 extern tupleschema *tupleschema_mask(tupleschema *schema,...);
 
 /**
- * The TUPLEITEMINIT macro is used for initializing a tupleschema
- * record appropriately for a given arity and corresponding sequence
- * of parts itemkeyfun pointers.
+ * \brief Return 1/0 to indicate whether the query matches the item.
+ *
+ * \related tupleschema
  */
-#define TUPLEITEMINIT(arity, ... ) {   \
-       .functions = {                          \
-           .hashcode = tupleitem_hashcode,     \
-           .haskey = tupleitem_haskey,         \
-           .itemkey = tupleitem_itemkey,       \
-           .releasekey = tupleitem_releasekey  \
-       },                                      \
-           .arity = arity,                     \
-           .schema = { __VA_ARGS__ }           \
-    }
+extern int tupleschema_match(tupleschema *def,tuple *query,tuple *item);
+
+/**
+ * \brief Generic macro to determine the number of expressions in a
+ * __VA_ARGS__
+ *
+ * \related tupleschema
+ */
+#define NUMARGS(...) (sizeof((void*[]){__VA_ARGS__})/sizeof(void*))
+
+/**
+ * \brief Create a tuple with the given values.
+ *
+ * This invokes \ref tuple_create to allocate and assign a void*
+ * array with the given values.
+ *
+ * \related tupleschema
+ */
+#define TUPLE(...) tuple_create( NUMARGS(__VA_ARGS__), __VA_ARGS__ )
+
+/**
+ * \brief Create a \ref tupleschema with the given column "types".
+ *
+ * This invokes \ref tupleschema_create to allocate and initialize a
+ * \ref tupleschema for the given columns via the \ref TUPLE macro.
+ *
+ * \related tupleschema
+ */
+#define TUPLESCHEMA(...) \
+    tupleschema_create( NUMARGS( __VA_ARGS__ ), TUPLE( __VA_ARGS__ ) )
+
 
 #endif