mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r14] Preliminary checkin of dataset code, to allow the interface & code to be shared.
Everything except the H5Dwrite should be working (or have sections of code commented about features to implement).
This commit is contained in:
parent
e251f45b87
commit
dd0fbd5b00
132
src/H5D.c
132
src/H5D.c
@ -83,7 +83,7 @@ static herr_t H5D_init_interface(void)
|
||||
--------------------------------------------------------------------------*/
|
||||
hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name)
|
||||
{
|
||||
H5D_dataset_t *new_dataset; /* new dataset object to create */
|
||||
H5D_dataset_t *new_dset; /* new dataset object to create */
|
||||
hatom_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER(H5D_create, H5D_init_interface, FAIL);
|
||||
@ -92,13 +92,21 @@ hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name)
|
||||
H5ECLEAR;
|
||||
|
||||
/* Allocate space for the new data-type */
|
||||
if((new_dataset=HDmalloc(sizeof(H5D_dataset_t)))==NULL)
|
||||
if((new_dset=HDmalloc(sizeof(H5D_dataset_t)))==NULL)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);
|
||||
|
||||
/* Initialize the dimensionality object */
|
||||
/* new_dset->file=? */
|
||||
new_dset->parent=owner_id; /* set the owner's ID */
|
||||
new_dset->name=HDstrdup(name); /* make a copy of the dataset name */
|
||||
new_dset->modified=BTRUE; /* Yep, we're new... */
|
||||
new_dset->type=0;
|
||||
new_dset->dim=0;
|
||||
new_dset->header=(-1); /* don't know where we are... */
|
||||
new_dset->data=(-1); /* don't know where we should put the data, either... */
|
||||
|
||||
/* Register the new datatype and get an ID for it */
|
||||
if((ret_value=H5Aregister_atom(H5_DATASET, (const VOIDP)new_dataset))==FAIL)
|
||||
if((ret_value=H5Aregister_atom(H5_DATASET, (const VOIDP)new_dset))==FAIL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);
|
||||
|
||||
done:
|
||||
@ -112,6 +120,115 @@ done:
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5D_create() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5Dset_info
|
||||
PURPOSE
|
||||
Set the type and dimensionality of a dataset.
|
||||
USAGE
|
||||
herr_t H5Dset_info(oid)
|
||||
hatom_t oid; IN: Dataset object to modify
|
||||
hatom_t tid; IN: Datatype object to use as node element
|
||||
hatom_t did; IN: Dimensionality object to use as dataspace
|
||||
RETURNS
|
||||
SUCCEED/FAIL
|
||||
DESCRIPTION
|
||||
This function sets the datatype and dataspace of a dataset.
|
||||
--------------------------------------------------------------------------*/
|
||||
herr_t H5Dset_info(hatom_t oid, hatom_t tid, hatom_t did)
|
||||
{
|
||||
H5D_dataset_t *dataset; /* dataset object to release */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER(H5Dset_info, H5D_init_interface, FAIL);
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
|
||||
/* Check that we've received correctly typed parameters */
|
||||
if(H5Aatom_group(tid)!=H5_DATATYPE || H5Aatom_group(did)!=H5_DATASPACE)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
|
||||
|
||||
/* Get the object */
|
||||
if((dataset=H5Aatom_object(oid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
/* Check that the datatype & dataspace haven't already been initialized */
|
||||
if(dataset->type!=0 || dataset->dim!=0)
|
||||
HGOTO_ERROR(H5E_FUNC, H5E_ALREADYINIT, FAIL);
|
||||
|
||||
dataset->type=tid;
|
||||
dataset->dim=did;
|
||||
dataset->modified=BTRUE; /* indicate the values have changed */
|
||||
|
||||
done:
|
||||
if(ret_value == FAIL)
|
||||
{ /* Error condition cleanup */
|
||||
|
||||
} /* end if */
|
||||
|
||||
/* Normal function cleanup */
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5Dset_info() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5Dwrite
|
||||
PURPOSE
|
||||
Write data for a dataset
|
||||
USAGE
|
||||
herr_t H5Dset_info(oid)
|
||||
hatom_t oid; IN: Dataset object to modify
|
||||
hatom_t did; IN: Dimensionality object to use as dataspace for I/O
|
||||
VOIDP buf; IN: Buffer with data to write to the file
|
||||
RETURNS
|
||||
SUCCEED/FAIL
|
||||
DESCRIPTION
|
||||
This function writes dataset object data to the file. The dataspace
|
||||
ID determines the slice/hyper-slab/portion of the dataset to write.
|
||||
H5P_SCALAR is a special value which indicates that the entire dataset is
|
||||
to be written out. (For datasets which have a scalar dataspace for the
|
||||
entire dataset, this is somewhat redundant.... :-)
|
||||
--------------------------------------------------------------------------*/
|
||||
herr_t H5Dwrite(hatom_t oid, hatom_t did, VOIDP buf)
|
||||
{
|
||||
H5D_dataset_t *dataset; /* dataset object to release */
|
||||
uintn towrite; /* number of bytes to write out */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER(H5Dset_info, H5D_init_interface, FAIL);
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
|
||||
/* Check that we've received correctly typed parameters */
|
||||
if(H5Aatom_group(did)!=H5_DATASPACE)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL);
|
||||
if(buf==NULL)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
|
||||
|
||||
/* Get the object */
|
||||
if((dataset=H5Aatom_object(oid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
/* Check that the datatype & dataspace haven't already been initialized */
|
||||
if(dataset->type==0 || dataset->dim==0)
|
||||
HGOTO_ERROR(H5E_FUNC, H5E_UNINITIALIZED, FAIL);
|
||||
|
||||
/* towrite=H5Tsize(dataset->type)*H5Pnelem(did); */
|
||||
/* Check memory to disk datatype conversions, etc. */
|
||||
/* data out */
|
||||
|
||||
done:
|
||||
if(ret_value == FAIL)
|
||||
{ /* Error condition cleanup */
|
||||
|
||||
} /* end if */
|
||||
|
||||
/* Normal function cleanup */
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
} /* end H5Dset_info() */
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5D_release
|
||||
@ -130,7 +247,7 @@ herr_t H5D_release(hatom_t oid)
|
||||
H5D_dataset_t *dataset; /* dataset object to release */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER(H5Drelease, H5D_init_interface, FAIL);
|
||||
FUNC_ENTER(H5D_release, H5D_init_interface, FAIL);
|
||||
|
||||
/* Clear errors and check args and all the boring stuff. */
|
||||
H5ECLEAR;
|
||||
@ -138,6 +255,13 @@ herr_t H5D_release(hatom_t oid)
|
||||
/* Chuck the object! :-) */
|
||||
if((dataset=H5Aremove_atom(oid))==NULL)
|
||||
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
|
||||
/* Check if we have information to flush to the file... */
|
||||
if(dataset->modified==BTRUE)
|
||||
{
|
||||
/* Flush object header, etc. to the file... */
|
||||
} /* end if */
|
||||
if(dataset->name!=NULL)
|
||||
HDfree(dataset->name);
|
||||
HDfree(dataset);
|
||||
|
||||
done:
|
||||
|
@ -19,6 +19,17 @@
|
||||
#ifndef H5DPRIVATE_H
|
||||
#define H5DPRIVATE_H
|
||||
|
||||
typedef struct {
|
||||
hatom_t file; /* ID of the file-store of this object */
|
||||
hatom_t parent; /* ID of the parent of this object (objects in the root-directory should have the file ID here, otherwise the directory ID is here) */
|
||||
char *name; /* Name of dataset */
|
||||
hbool_t modified; /* Whether the dataset has been modified from version on disk */
|
||||
hatom_t type; /* ID of Datatype of the dataset */
|
||||
hatom_t dim; /* ID of Dimensionality of the dataset */
|
||||
haddr_t header; /* offset of the object header for this dataset */
|
||||
haddr_t data; /* offset of the data in the file */
|
||||
} H5D_dataset_t;
|
||||
|
||||
#include "H5Dproto.h"
|
||||
#define H5D_RESERVED_ATOMS 0
|
||||
|
||||
|
@ -19,10 +19,6 @@
|
||||
#ifndef H5DPROTO_H
|
||||
#define H5DPROTO_H
|
||||
|
||||
typedef struct {
|
||||
int foo; /* stop compiler from whining right now */
|
||||
} H5D_dataset_t;
|
||||
|
||||
#if defined c_plusplus || defined __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@ -30,11 +26,12 @@ extern "C"
|
||||
|
||||
/* Functions in H5D.c */
|
||||
hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name);
|
||||
herr_t H5Dset_info(hatom_t oid, hatom_t tid, hatom_t did);
|
||||
herr_t H5D_release(hatom_t oid);
|
||||
|
||||
#if defined c_plusplus || defined __cplusplus
|
||||
}
|
||||
#endif /* c_plusplus || __cplusplus */
|
||||
|
||||
#endif /* H5PPROTO_H */
|
||||
#endif /* H5DPROTO_H */
|
||||
|
||||
|
@ -41,7 +41,7 @@ typedef struct {
|
||||
|
||||
/* Structure for storing information any datatype */
|
||||
typedef struct {
|
||||
h5_atomic_type_t dt; /* Atomic type of this object */
|
||||
h5_atomic_type_t dt; /* Base type of this object */
|
||||
char *name; /* Name of datatype */
|
||||
h5_compound_info_t *ci; /* Information for compound datatypes */
|
||||
} h5_datatype_t;
|
||||
|
@ -42,12 +42,12 @@ extern "C"
|
||||
|
||||
/* Functions in H5T.c */
|
||||
hatom_t H5T_create(hatom_t owner_id, hobjtype_t type, const char *name);
|
||||
herr_t H5T_release(hatom_t oid);
|
||||
uint32 H5Tget_num_fields(hatom_t tid);
|
||||
hbool_t H5Tis_field_atomic(hatom_t tid,uintn fidx);
|
||||
hbool_t H5Tis_atomic(hatom_t tid);
|
||||
herr_t H5Tset_type(hatom_t tid,hatom_t base,uint8 len,uint8 arch);
|
||||
uintn H5Tsize(hatom_t tid, uint8 len, uint8 arch, hbool_t mem_flag);
|
||||
herr_t H5T_release(hatom_t oid);
|
||||
herr_t H5Tadd_field (hatom_t tid, const char *name, hatom_t base, uint8 len,
|
||||
uint8 arch, hatom_t space);
|
||||
herr_t H5Tget_fields(hatom_t tid, hatom_t *field_list);
|
||||
|
Loading…
Reference in New Issue
Block a user