Commit 8cdfbb37 by Celine Mercier

Documentation for views and reworked the code a little

parent 0a55e265
......@@ -20,39 +20,40 @@ cdef extern from "obiview.h" nogil:
extern const_char_p ID_COLUMN
extern const_char_p DEFINITION_COLUMN
struct Column_reference_t :
const_char_p column_name
obiversion_t version
ctypedef Column_reference_t* Column_reference_p
struct Obiview_t :
OBIDMS_p dms
const_char_p name
const_char_p created_from
const_char_p view_type
bint read_only
OBIDMS_column_p line_selection
OBIDMS_column_p new_line_selection
OBIDMS_column_p columns
bint read_only
Column_reference_t line_selection_reference
index_t line_count
int column_count
OBIDMS_column_p columns
const_char_p comments
ctypedef Obiview_t* Obiview_p
struct Column_reference_t :
const_char_p column_name
obiversion_t version
ctypedef Column_reference_t* Column_reference_p
struct Obiview_infos_t :
int view_number
int column_count
index_t line_count
time_t creation_date
const_char_p name
const_char_p created_from
time_t creation_date
const_char_p view_type
bint all_lines
Column_reference_t line_selection
index_t line_count
int column_count
Column_reference_p column_references
const_char_p view_type
const_char_p comments
ctypedef Obiview_infos_t* Obiview_infos_p
......
......@@ -78,12 +78,41 @@ static char* build_obiview_file_name();
int create_obiview_file(int dms_file_descriptor);
// TODO doc
/**
* Internal function preparing to set a value in a column, in the context of a view.
*
* The function checks that the view is not read-only, clones the column or all columns if needed,
* and updates the line count if needed.
*
* @param view The view.
* @param column_pp A pointer on the pointer on the column, to allow replacing the column if it is cloned.
* @param line_nb_p A pointer on the index of the line that will be modified, to allow replacing it if needed.
*
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since April 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, index_t* line_nb_p);
// TODO doc
int prepare_to_get_value_in_column(Obiview_p view, OBIDMS_column_p column, index_t* line_nb_p);
/**
* Internal function preparing to get a value from a column, in the context of a view.
*
* The function checks that the line index is not beyond the current line count of the view,
* and modifies it if there is a line selection associated with the view.
*
* @param view The view.
* @param line_nb_p A pointer on the index of the line, to allow replacing it if needed.
*
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since April 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int prepare_to_get_value_from_column(Obiview_p view, index_t* line_nb_p);
/************************************************************************
......@@ -256,7 +285,7 @@ int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, i
}
int prepare_to_get_value_from_column(Obiview_p view, OBIDMS_column_p column, index_t* line_nb_p)
int prepare_to_get_value_from_column(Obiview_p view, index_t* line_nb_p)
{
if (((*line_nb_p)+1) > (view->line_count))
{
......@@ -379,7 +408,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
return NULL;
view->line_count = view_to_clone->line_count;
}
// If there is a new line selection, build it by combining it with the pre-existing one if there is one
// If there is a new line selection, build it by combining it with the one from the view to clone if there is one
else if (line_selection != NULL)
{
view->line_selection = obi_create_column(view->dms, LINES_COLUMN_NAME, OBI_IDX, 0, 1, LINES_COLUMN_NAME, NULL, NULL);
......@@ -566,7 +595,7 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name)
return NULL;
}
// Find and open view that should be read with the line selection associated
// Find and open the view that should be read with the line selection associated
view_number = -1;
if (view_name == NULL) // If view name is NULL, open the latest view TODO discuss
view_number = (header->view_count) - 1;
......@@ -927,7 +956,7 @@ int obi_select_line(Obiview_p view, index_t line_nb)
return -1;
}
// If column for line selection doesn't already exists, create it and store its informations
// If the column for line selection doesn't already exists, create it and store its informations
if ((view->new_line_selection) == NULL)
{
view->new_line_selection = obi_create_column(view->dms, LINES_COLUMN_NAME, OBI_IDX, 0, 1, LINES_COLUMN_NAME, NULL, NULL);
......@@ -1240,7 +1269,7 @@ int obi_column_set_obibool_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p
obibool_t obi_column_get_obibool_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, index_t element_idx)
{
if (prepare_to_get_value_from_column(view, column, &line_nb) < 0)
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
return OBIBool_NA;
return obi_column_get_obibool_with_elt_idx(column, line_nb, element_idx);
}
......@@ -1278,7 +1307,7 @@ int obi_column_set_obichar_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p
obichar_t obi_column_get_obichar_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, index_t element_idx)
{
if (prepare_to_get_value_from_column(view, column, &line_nb) < 0)
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
return OBIChar_NA;
return obi_column_get_obichar_with_elt_idx(column, line_nb, element_idx);
}
......@@ -1316,7 +1345,7 @@ int obi_column_set_obifloat_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p
obifloat_t obi_column_get_obifloat_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, index_t element_idx)
{
if (prepare_to_get_value_from_column(view, column, &line_nb) < 0)
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
return OBIFloat_NA;
return obi_column_get_obifloat_with_elt_idx(column, line_nb, element_idx);
}
......@@ -1354,7 +1383,7 @@ int obi_column_set_obiint_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p c
obiint_t obi_column_get_obiint_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, index_t element_idx)
{
if (prepare_to_get_value_from_column(view, column, &line_nb) < 0)
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
return OBIInt_NA;
return obi_column_get_obiint_with_elt_idx(column, line_nb, element_idx);
}
......@@ -1392,7 +1421,7 @@ int obi_column_set_obiseq_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p c
char* obi_column_get_obiseq_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, index_t element_idx)
{
if (prepare_to_get_value_from_column(view, column, &line_nb) < 0)
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
return OBISeq_NA;
return obi_column_get_obiseq_with_elt_idx(column, line_nb, element_idx);
}
......@@ -1430,7 +1459,7 @@ int obi_column_set_obistr_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p c
const char* obi_column_get_obistr_with_elt_idx_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, index_t element_idx)
{
if (prepare_to_get_value_from_column(view, column, &line_nb) < 0)
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
return OBIStr_NA;
return obi_column_get_obistr_with_elt_idx(column, line_nb, element_idx);
}
......
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