ncdf4a13/libsrc/ncio.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright 1996, University Corporation for Atmospheric Research
00003  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
00004  */
00005 /* $Id: ncio.h,v 1.27 2006/01/03 04:56:28 russ Exp $ */
00006 
00007 #ifndef _NCIO_H_
00008 #define _NCIO_H_
00009 
00010 #include <stddef.h>     /* size_t */
00011 #include <sys/types.h>  /* off_t */
00012 #include "netcdf.h"
00013 
00014 typedef struct ncio ncio;       /* forward reference */
00015 
00016 /*
00017  * A value which is an invalid off_t
00018  */
00019 #define OFF_NONE  ((off_t)(-1))
00020 
00021 /*
00022  * Flags used by the region layer,
00023  *  'rflags' argument to ncio.rel() and ncio.get().
00024  */
00025 #define RGN_NOLOCK      0x1     /* Don't lock region.
00026                                  * Used when contention control handled
00027                                  * elsewhere.
00028                                  */
00029 #define RGN_NOWAIT      0x2     /* return immediate if can't lock, else wait */
00030 
00031 #define RGN_WRITE       0x4     /* we intend to modify, else read only */
00032 
00033 #define RGN_MODIFIED    0x8     /* we did modify, else, discard */
00034 
00035 
00036 /*
00037  * The next four typedefs define the signatures
00038  * of function pointers in struct ncio below.
00039  * They are not used outside of this file and ncio.h,
00040  * They just make some casts in the ncio.c more readable.
00041  */
00042         /*
00043          * Indicate that you are done with the region which begins
00044          * at offset. Only reasonable flag value is RGN_MODIFIED.
00045          */
00046 typedef int ncio_relfunc(ncio *const nciop,
00047                  off_t offset, int rflags);
00048 
00049         /*
00050          * Request that the region (offset, extent)
00051          * be made available through *vpp.
00052          */
00053 typedef int ncio_getfunc(ncio *const nciop,
00054                         off_t offset, size_t extent,
00055                         int rflags,
00056                         void **const vpp);
00057 
00058         /*
00059          * Like memmove(), safely move possibly overlapping data.
00060          * Only reasonable flag value is RGN_NOLOCK.
00061          */
00062 typedef int ncio_movefunc(ncio *const nciop, off_t to, off_t from,
00063                         size_t nbytes, int rflags);
00064 
00065         /*
00066          * Write out any dirty buffers to disk and
00067          * ensure that next read will get data from disk.
00068          */
00069 typedef int ncio_syncfunc(ncio *const nciop);
00070 
00071         /*
00072          * Don't call this. 
00073          * Internal function called at close to
00074          * free up anything hanging off pvt;
00075          */
00076 typedef void ncio_freefunc(void *const pvt);
00077 
00078 /* Get around cplusplus "const xxx in class ncio without constructor" error */
00079 #if defined(__cplusplus)
00080 #define NCIO_CONST
00081 #else
00082 #define NCIO_CONST const
00083 #endif
00084 
00085 /*
00086  * netcdf i/o abstraction
00087  */
00088 struct ncio {
00089         /*
00090          * A copy of the ioflags argument passed in to ncio_open()
00091          * or ncio_create().
00092          */
00093         int ioflags;
00094 
00095         /*
00096          * The file descriptor of the netcdf file.
00097          * This gets handed to the user as the netcdf id.
00098          */
00099         NCIO_CONST int fd;
00100 
00101         /* member functions do the work */
00102 
00103         ncio_relfunc *NCIO_CONST rel;
00104 
00105         ncio_getfunc *NCIO_CONST get;
00106 
00107         ncio_movefunc *NCIO_CONST move;
00108 
00109         ncio_syncfunc *NCIO_CONST sync;
00110 
00111         ncio_freefunc *NCIO_CONST free; /* Implementation private */
00112 
00113         /*
00114          * A copy of the 'path' argument passed in to ncio_open()
00115          * or ncio_create(). Used by ncabort() to remove (unlink)
00116          * the file and by error messages.
00117          */
00118         const char *path;
00119 
00120         /* implementation private stuff */
00121         void *NCIO_CONST pvt;
00122 };
00123 
00124 #undef NCIO_CONST
00125 
00126 extern int
00127 ncio_create(const char *path, int ioflags,
00128         size_t initialsz,
00129         off_t igeto, size_t igetsz, size_t *sizehintp,
00130         ncio **nciopp, void **const igetvpp);
00131 
00132 extern int
00133 ncio_open(const char *path,
00134         int ioflags,
00135         off_t igeto, size_t igetsz, size_t *sizehintp,
00136         ncio **nciopp, void **const igetvpp);
00137 
00138 extern int 
00139 ncio_close(ncio *nciop, int doUnlink);
00140 
00141 extern int
00142 ncio_filesize(ncio *nciop, off_t *filesizep);
00143 
00144 extern int
00145 ncio_pad_length(ncio *nciop, off_t length);
00146 
00147 #endif /* _NCIO_H_ */

Generated on Thu Mar 16 18:10:09 2006 for nco by  doxygen 1.4.4