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 data_object.h 00022 * 00023 * Data object ADT API. 00024 */ 00025 #ifndef _DATA_OBJECT_H 00026 #define _DATA_OBJECT_H 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #include <sys/types.h> 00033 #include <stdint.h> 00034 00035 /** 00036 * @defgroup data_object Data Object 00037 * 00038 * A data object is an abstraction for objects that can provide data. 00039 * It provides a common API to transparently get the data 00040 * regardless of the particular source they come from. 00041 * 00042 * The two main data object types are the memory data object and the file 00043 * data object. To create a data object one must use the provided constructor 00044 * for the particular type. 00045 * 00046 * @{ 00047 */ 00048 00049 /** 00050 * Opaque type for data object ADT. 00051 */ 00052 typedef struct data_object data_object_t; 00053 00054 00055 /** 00056 * Flags for the usage of data returned by data_object_get_data(). 00057 */ 00058 typedef enum { 00059 DATA_OBJECT_READ = 1, /**< Data will be used just for reading */ 00060 DATA_OBJECT_WRITE = 2, /**< Data will be used just for writing */ 00061 DATA_OBJECT_RW = 3 /**< Data will be used for both reading and writing */ 00062 } data_object_flags; 00063 00064 int data_object_get_data(data_object_t *obj, void **buf, off_t offset, 00065 off_t *length, data_object_flags flags); 00066 00067 int data_object_free(data_object_t *obj); 00068 00069 int data_object_update_usage(void *obj, int change); 00070 00071 int data_object_get_size(data_object_t *obj, off_t *size); 00072 00073 int data_object_compare(int *result, data_object_t *obj1, data_object_t *obj2); 00074 00075 /** @} */ 00076 00077 #ifdef __cplusplus 00078 } 00079 #endif 00080 00081 #endif