00001 /* 00002 * Copyright 2008, 2009 Alexandros Frantzis, Michael Iatrou 00003 * 00004 * This file is part of libbls. 00005 * 00006 * libbls is free software: you can redistribute it and/or modify it under the 00007 * terms of the GNU Lesser General Public License as published by the Free Software 00008 * Foundation, either version 3 of the License, or (at your option) any later 00009 * version. 00010 * 00011 * libbls is distributed in the hope that it will be useful, but WITHOUT ANY 00012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00014 * details. 00015 * 00016 * You should have received a copy of the GNU General Public License along with 00017 * libbls. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 /** 00021 * @file segcol.h 00022 * 00023 * Segment Collection ADT 00024 */ 00025 #ifndef _SEGCOL_H 00026 #define _SEGCOL_H 00027 00028 #include <sys/types.h> 00029 #include "segment.h" 00030 00031 /** 00032 * @defgroup segcol Segment Collection 00033 * 00034 * A Segment Collection manages a collection of segments virtually arranged 00035 * in a continuous linear space. 00036 * 00037 * There may be many implementations of the Segment Collection ADT, each with 00038 * its own performance characteristics. To create a Segment Collection one 00039 * must use the constructor functions defined in each implementation 00040 * (eg segcol_list_new()). 00041 * 00042 * A note on error codes: all functions return EINVAL when an invalid range 00043 * is specified (eg an offset is outside the limits of the virtual space of 00044 * a Segment Collection). 00045 * 00046 * @{ 00047 */ 00048 00049 /** 00050 * Opaque type for segment collection ADT. 00051 */ 00052 typedef struct segcol segcol_t; 00053 00054 /** 00055 * Opaque type for segment collection iterator. 00056 */ 00057 typedef struct segcol_iter segcol_iter_t; 00058 00059 int segcol_free(segcol_t *segcol); 00060 00061 int segcol_append(segcol_t *segcol, segment_t *seg); 00062 00063 int segcol_insert(segcol_t *segcol, off_t offset, segment_t *seg); 00064 00065 int segcol_delete(segcol_t *segcol, segcol_t **deleted, off_t offset, off_t length); 00066 00067 int segcol_find(segcol_t *segcol, segcol_iter_t **iter, off_t offset); 00068 00069 /** 00070 * @name Iterator functions 00071 * 00072 * @{ 00073 */ 00074 int segcol_iter_new(segcol_t *segcol, segcol_iter_t **iter); 00075 00076 int segcol_iter_next(segcol_iter_t *iter); 00077 00078 int segcol_iter_is_valid(segcol_iter_t *iter, int *valid); 00079 00080 int segcol_iter_get_segment(segcol_iter_t *iter, segment_t **seg); 00081 00082 int segcol_iter_get_mapping(segcol_iter_t *iter, off_t *mapping); 00083 00084 int segcol_iter_free(segcol_iter_t *iter); 00085 00086 /** @} */ 00087 00088 int segcol_get_size(segcol_t *segcol, off_t *size); 00089 00090 /** @} */ 00091 00092 #endif /* _SEGCOL_H */