Overture  Version 25
Macros | Functions
HDF_DataBase.C File Reference
#include "HDF_DataBase.h"
#include "DataBaseBuffer.h"
#include "ReferenceCountingList.h"
#include "mfhdf.h"
Include dependency graph for HDF_DataBase.C:

Macros

#define NUM_APP_DIMS   4
 
#define PUT(type, HDFType)   int HDF_DataBase:: put( const type & x, const aString & name ) { assert(rcData!=NULL); if( file_id<=0 || sd_id<=0 ) {printf("HDF_DataBase::put(type,name):ERROR: file_id=%i and sd_id=%i when attempting to put name=%s\n",file_id,sd_id,(const char*)name);assert( file_id > 0 && sd_id > 0 ); }if( accessMode!=write ) { cout << "HDF_DataBase:ERROR:put: cannot put a float/double/int to a read-only file, name =" << (const char*) name << endl; return 1; } if( mode==streamOutputMode ) { dataBaseBuffer->putToBuffer( 1,&x ); return 0; } if( dataBaseBuffer!=NULL && (mode==normalMode || mode==noStreamMode) ) closeStream(); /* flush any stream buffers */ /* Create a Vdata to store the array values, set its name and class. */ int32 vdata_id = VSattach(file_id, -1, (accessMode==read ? "r" : "w")); if( vdata_id==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSattach\n"); return 1; } int32 istat =VSsetname(vdata_id, (const char *)name); VSsetclass(vdata_id, #type ); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSsetclass\n"); return 1; } /* Specify the Vdata data type, name and the order. */ istat=VSfdefine(vdata_id, (const char *)name, HDFType, 1); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSdefine\n"); throw "error"; /* return 1; */ } /* Set the field names. */ istat=VSsetfields(vdata_id, (const char *)name); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSsetfields\n"); return 1; } /* Write the buffered data into the Vdata object. */ int num=1; istat = VSwrite(vdata_id, (unsigned char*)(&x), num, FULL_INTERLACE); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSwrite\n"); return 1; } /* Insert the Vdata into the Vgroup. */ istat=Vinsert(rcData->vgroup_id, vdata_id); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSinsert\n"); return 1; } /* Detach from the Vdata. */ istat=VSdetach(vdata_id); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSdetach\n"); return 1; } return 0; }
 
#define GET(type, HDFType)   int HDF_DataBase:: get( type & x, const aString & name ) const { assert(rcData!=NULL); if( file_id<=0 || sd_id<=0 ) {printf("HDF_DataBase::get(type[],name):ERROR: file_id=%i and sd_id=%i when attempting to put name=%s\n",file_id,sd_id,(const char*)name);assert( file_id > 0 && sd_id > 0 ); }if( mode==streamInputMode ) { dataBaseBuffer->getFromBuffer( 1,&x ); return 0; } if( dataBaseBuffer!=NULL && (mode==normalMode || mode==noStreamMode) ) closeStream(); /* flush any stream buffers */ /* get the total number of tag/reference pairs in the vgroup */ int npairs = Vntagrefs(rcData->vgroup_id); int32 vdata_tag, vdata_ref; char vdata_name[VSNAMELENMAX]; int found=FALSE; int i; for( i=0; i<npairs; i++ ) { /* get tag and ref */ int status = Vgettagref(rcData->vgroup_id, i, &vdata_tag, &vdata_ref ); if( debug & 2 ) printf(" get: i=%i, tag=%i, ref=%i\n", i,vdata_tag,vdata_ref); if( Visvs(rcData->vgroup_id,vdata_ref) ) { /* this is a vdata */ /* get identifier for vdata */ int32 vdata_id=VSattach(file_id,vdata_ref,(accessMode==read ? "r" : "w")); /* get name of the vdata */ VSgetname(vdata_id,vdata_name); if( debug & 2 ) printf(" get: vdata_name = %s\n",vdata_name); if( name==vdata_name ) { if( debug & 2 ) cout << "get: item found! \n"; found=TRUE; int32 n_records; VSQuerycount( vdata_id, &n_records ); if( debug & 2 ) printf(" get: n_records=%i \n",n_records); VSread(vdata_id, (unsigned char*)&x, n_records, FULL_INTERLACE ); VSdetach(vdata_id); break; } VSdetach(vdata_id); } } if( !found && issueWarnings ) { cout << "get: ERROR searching for " << (const char *)name << endl; } return found ? 0 : 1; }
 

Functions

int HDF_DataBase:: get (floatSerialArray &x, const aString &name, Index *Iv) const
 
int HDF_DataBase:: get (intSerialArray &x, const aString &name, Index *Iv) const
 
int HDF_DataBase:: get (doubleSerialArray &x, const aString &name, Index *Iv) const
 
int HDF_DataBase:: getDistributed (floatArray &x, const aString &name) const
 
int HDF_DataBase:: getDistributed (intArray &x, const aString &name) const
 
int HDF_DataBase:: getDistributed (doubleArray &x, const aString &name) const
 

Macro Definition Documentation

#define GET (   type,
  HDFType 
)    int HDF_DataBase:: get( type & x, const aString & name ) const { assert(rcData!=NULL); if( file_id<=0 || sd_id<=0 ) {printf("HDF_DataBase::get(type[],name):ERROR: file_id=%i and sd_id=%i when attempting to put name=%s\n",file_id,sd_id,(const char*)name);assert( file_id > 0 && sd_id > 0 ); }if( mode==streamInputMode ) { dataBaseBuffer->getFromBuffer( 1,&x ); return 0; } if( dataBaseBuffer!=NULL && (mode==normalMode || mode==noStreamMode) ) closeStream(); /* flush any stream buffers */ /* get the total number of tag/reference pairs in the vgroup */ int npairs = Vntagrefs(rcData->vgroup_id); int32 vdata_tag, vdata_ref; char vdata_name[VSNAMELENMAX]; int found=FALSE; int i; for( i=0; i<npairs; i++ ) { /* get tag and ref */ int status = Vgettagref(rcData->vgroup_id, i, &vdata_tag, &vdata_ref ); if( debug & 2 ) printf(" get: i=%i, tag=%i, ref=%i\n", i,vdata_tag,vdata_ref); if( Visvs(rcData->vgroup_id,vdata_ref) ) { /* this is a vdata */ /* get identifier for vdata */ int32 vdata_id=VSattach(file_id,vdata_ref,(accessMode==read ? "r" : "w")); /* get name of the vdata */ VSgetname(vdata_id,vdata_name); if( debug & 2 ) printf(" get: vdata_name = %s\n",vdata_name); if( name==vdata_name ) { if( debug & 2 ) cout << "get: item found! \n"; found=TRUE; int32 n_records; VSQuerycount( vdata_id, &n_records ); if( debug & 2 ) printf(" get: n_records=%i \n",n_records); VSread(vdata_id, (unsigned char*)&x, n_records, FULL_INTERLACE ); VSdetach(vdata_id); break; } VSdetach(vdata_id); } } if( !found && issueWarnings ) { cout << "get: ERROR searching for " << (const char *)name << endl; } return found ? 0 : 1; }
#define NUM_APP_DIMS   4

Referenced by get(), and getDistributed().

#define PUT (   type,
  HDFType 
)    int HDF_DataBase:: put( const type & x, const aString & name ) { assert(rcData!=NULL); if( file_id<=0 || sd_id<=0 ) {printf("HDF_DataBase::put(type,name):ERROR: file_id=%i and sd_id=%i when attempting to put name=%s\n",file_id,sd_id,(const char*)name);assert( file_id > 0 && sd_id > 0 ); }if( accessMode!=write ) { cout << "HDF_DataBase:ERROR:put: cannot put a float/double/int to a read-only file, name =" << (const char*) name << endl; return 1; } if( mode==streamOutputMode ) { dataBaseBuffer->putToBuffer( 1,&x ); return 0; } if( dataBaseBuffer!=NULL && (mode==normalMode || mode==noStreamMode) ) closeStream(); /* flush any stream buffers */ /* Create a Vdata to store the array values, set its name and class. */ int32 vdata_id = VSattach(file_id, -1, (accessMode==read ? "r" : "w")); if( vdata_id==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSattach\n"); return 1; } int32 istat =VSsetname(vdata_id, (const char *)name); VSsetclass(vdata_id, #type ); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSsetclass\n"); return 1; } /* Specify the Vdata data type, name and the order. */ istat=VSfdefine(vdata_id, (const char *)name, HDFType, 1); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSdefine\n"); throw "error"; /* return 1; */ } /* Set the field names. */ istat=VSsetfields(vdata_id, (const char *)name); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSsetfields\n"); return 1; } /* Write the buffered data into the Vdata object. */ int num=1; istat = VSwrite(vdata_id, (unsigned char*)(&x), num, FULL_INTERLACE); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSwrite\n"); return 1; } /* Insert the Vdata into the Vgroup. */ istat=Vinsert(rcData->vgroup_id, vdata_id); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSinsert\n"); return 1; } /* Detach from the Vdata. */ istat=VSdetach(vdata_id); if( istat==FAIL ) { printf("HDF_DataBase::put(" #type "): ERROR return from VSdetach\n"); return 1; } return 0; }

Function Documentation

int HDF_DataBase:: get ( floatSerialArray &  x,
const aString name,
Index *  Iv 
) const

References assert, debug, FALSE, NULL, NUM_APP_DIMS, and TRUE.

int HDF_DataBase:: get ( intSerialArray &  x,
const aString name,
Index *  Iv 
) const

References assert, debug, FALSE, NULL, NUM_APP_DIMS, and TRUE.

int HDF_DataBase:: get ( doubleSerialArray &  x,
const aString name,
Index *  Iv 
) const

References assert, debug, FALSE, NULL, NUM_APP_DIMS, and TRUE.

int HDF_DataBase:: getDistributed ( floatArray &  x,
const aString name 
) const

References assert, debug, FALSE, max(), min(), NULL, NUM_APP_DIMS, S1, S2, and TRUE.

int HDF_DataBase:: getDistributed ( intArray &  x,
const aString name 
) const

References assert, debug, FALSE, max(), min(), NULL, NUM_APP_DIMS, S1, S2, and TRUE.

int HDF_DataBase:: getDistributed ( doubleArray &  x,
const aString name 
) const

References assert, debug, FALSE, max(), min(), NULL, NUM_APP_DIMS, S1, S2, and TRUE.