Closes issue #47 by storing each view in a separate file named with the
view's name and created upon view creation.
This commit is contained in:
@ -34,8 +34,6 @@
|
||||
*/
|
||||
#define VIEW_TYPE_MAX_LENGTH (1024) /**< The maximum length of the type name of a view.
|
||||
*/
|
||||
#define OBIVIEW_FILE_NAME "obiviews" /**< The default name of a view file.
|
||||
*/
|
||||
#define LINES_COLUMN_NAME "LINES" /**< The name of the column containing the line selections
|
||||
* in all views.
|
||||
*/
|
||||
@ -56,45 +54,6 @@
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Structure for an opened view.
|
||||
*/
|
||||
typedef struct Obiview {
|
||||
|
||||
OBIDMS_p dms; /**< A pointer on the DMS to which the view belongs.
|
||||
*/
|
||||
char name[OBIVIEW_NAME_MAX_LENGTH+1]; /**< Name of the view.
|
||||
*/
|
||||
char created_from[OBIVIEW_NAME_MAX_LENGTH+1]; /**< Name of the view from which that view was cloned if the view was cloned.
|
||||
*/
|
||||
char view_type[VIEW_TYPE_MAX_LENGTH+1]; /**< Type of the view if there is one.
|
||||
* Types existing: NUC_SEQS_VIEW.
|
||||
*/
|
||||
bool read_only; /**< Whether the view is read-only or can be modified.
|
||||
*/
|
||||
OBIDMS_column_p line_selection; /**< A pointer on the column containing the line selection
|
||||
* associated with the view if there is one.
|
||||
* This line selection is read-only, and when a line from the view is read,
|
||||
* it is this line selection that is used.
|
||||
*/
|
||||
OBIDMS_column_p new_line_selection; /**< A pointer on the column containing the new line selection being built
|
||||
* to associate with the view, if there is one.
|
||||
* When a line is selected with obi_select_line() or obi_select_lines(),
|
||||
* it is recorded in this line selection.
|
||||
*/
|
||||
index_t line_count; /**< The number of lines in the view. Refers to the number of lines in each
|
||||
* column of the view if line_selection is NULL, or to the line count of
|
||||
* line_selection if it is not NULL.
|
||||
*/
|
||||
int column_count; /**< The number of columns in the view.
|
||||
*/
|
||||
OBIDMS_column_p columns[MAX_NB_OPENED_COLUMNS]; /**< Array of pointers on all the columns of the view.
|
||||
*/
|
||||
char comments[OBIVIEW_COMMENTS_MAX_LENGTH+1]; /**< Comments, additional informations on the view.
|
||||
*/
|
||||
} Obiview_t, *Obiview_p;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Structure referencing a column by its name and its version.
|
||||
*/
|
||||
@ -112,8 +71,6 @@ typedef struct Column_reference {
|
||||
* Once a view has been written in the view file, it can not be modified and can only be read.
|
||||
*/
|
||||
typedef struct Obiview_infos {
|
||||
int view_number; /**< Number of the view in the view file.
|
||||
*/
|
||||
time_t creation_date; /**< Time at which the view was written in the view file.
|
||||
*/
|
||||
char name[OBIVIEW_NAME_MAX_LENGTH+1]; /**< Name of the view, used to identify it.
|
||||
@ -138,7 +95,29 @@ typedef struct Obiview_infos {
|
||||
} Obiview_infos_t, *Obiview_infos_p;
|
||||
|
||||
|
||||
// TODO : Combine the common elements of the Obiview_infos and Obiview structures in one structure used by both?
|
||||
/**
|
||||
* @brief Structure for an opened view.
|
||||
*/
|
||||
typedef struct Obiview {
|
||||
Obiview_infos_p infos; /**< A pointer on the mapped view informations.
|
||||
*/
|
||||
OBIDMS_p dms; /**< A pointer on the DMS to which the view belongs.
|
||||
*/
|
||||
bool read_only; /**< Whether the view is read-only or can be modified.
|
||||
*/
|
||||
OBIDMS_column_p line_selection; /**< A pointer on the column containing the line selection
|
||||
* associated with the view if there is one.
|
||||
* This line selection is read-only, and when a line from the view is read,
|
||||
* it is this line selection that is used.
|
||||
*/
|
||||
OBIDMS_column_p new_line_selection; /**< A pointer on the column containing the new line selection being built
|
||||
* to associate with the view, if there is one.
|
||||
* When a line is selected with obi_select_line() or obi_select_lines(),
|
||||
* it is recorded in this line selection.
|
||||
*/
|
||||
OBIDMS_column_p columns[MAX_NB_OPENED_COLUMNS]; /**< Array of pointers on all the columns of the view.
|
||||
*/
|
||||
} Obiview_t, *Obiview_p;
|
||||
|
||||
|
||||
/**
|
||||
@ -269,6 +248,37 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
||||
Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection, const char* comments);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Maps a view file and returns the mapped structure stored in it.
|
||||
*
|
||||
* @param dms A pointer on the OBIDMS.
|
||||
* @param view_name The unique name identifying the view.
|
||||
*
|
||||
* @returns A pointer on the mapped view infos structure.
|
||||
* @retval NULL if an error occurred.
|
||||
*
|
||||
* @since June 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
Obiview_infos_p obi_view_map_file(OBIDMS_p dms, const char* view_name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Unmaps a view file.
|
||||
*
|
||||
* @param dms A pointer on the OBIDMS.
|
||||
* @param view_infos A pointer on the mapped view infos structure.
|
||||
*
|
||||
* @returns A value indicating the success of the operation.
|
||||
* @retval 0 if the operation was successfully completed.
|
||||
* @retval -1 if an error occurred.
|
||||
*
|
||||
* @since June 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
int obi_view_unmap_file(OBIDMS_p dms, Obiview_infos_p view_infos);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Opens a view identified by its name stored in the view file.
|
||||
*
|
||||
|
Reference in New Issue
Block a user