Commit cdf33e55 authored by Nicolas Denoyelle's avatar Nicolas Denoyelle
Browse files

add lib copy function required in user iterators to build the function table...

add lib copy function required in user iterators to build the function table which require a copy function which may have to copy an opaque excit_t
parent 9afc3893
......@@ -93,7 +93,7 @@ int excit_get_func_table(excit_t it, struct excit_func_table_s **func_table)
it->dimension = 0; \
if (excit_ ##op## _func_table.alloc(it)) \
goto error; \
}
}
excit_t excit_alloc(enum excit_type_e type)
{
......@@ -201,6 +201,21 @@ int excit_type(excit_t it, enum excit_type_e *type)
return EXCIT_SUCCESS;
}
int excit_copy(excit_t dst, const excit_t src)
{
if (!dst ||
!src ||
!src->func_table ||
src->type != dst->type ||
src->dimension != dst->dimension)
return -EXCIT_EINVAL;
if (!src->func_table->copy)
return -EXCIT_ENOTSUP;
dst->func_table = src->func_table;
dst->dimension = src->dimension;
return src->func_table->copy(dst, src);
}
int excit_next(excit_t it, ssize_t *indexes)
{
if (!it || !it->func_table)
......
......@@ -198,6 +198,14 @@ excit_t excit_dup(const excit_t it);
*/
void excit_free(excit_t it);
/*
* Copy an iterator.
* "dst": the copy destination.
* "src": the iterator to copy
*/
int excit_copy(excit_t dst, const excit_t src);
/*
* Get the type of an iterator
* "it": an iterator.
......@@ -418,9 +426,9 @@ enum tleaf_it_policy_e {
* Initialize a tleaf iterator by giving its depth, levels arity and iteration policy.
* "it": a tleaf iterator
* "depth": the total number of levels of the tree, including leaves
* "arity": An array of size (depth-1). For each level, the number of children attached to a node. Leaves have no children, hence last level arity is ignored.
* "arity": An array of size (depth-1). For each level, the number of children attached to a node. Leaves have no children, hence last level arity is ignored. Arities are organized from root to leaves.
* "policy": A policy for iteration on leaves.
* "user_policy": If policy is TLEAF_POLICY_USER, then this argument must be an array of size (depth-1) providing the order (from 0 to (depth-2)) in wich levels are walked
* "user_policy": If policy is TLEAF_POLICY_USER, then this argument must be an array of size (depth-1) providing the order (from 0 to (depth-2)) in wich levels are walked.
* when resolving indexes. Underneath, a product iterator of range iterator returns indexes on last levels upon iterator queries. This set of indexes is then
* computed to a single leaf index. For instance TLEAF_POLICY_ROUND_ROBIN is obtained from walking from leaves to root whereas TLEAF_POLICY_SCATTER is
* obtained from walking from root to leaves.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment