36 #include <sys/types.h>
45 #include <D4BaseTypeFactory.h>
58 #include <Ancillary.h>
76 #define HDF5_NAME "h5"
82 extern void read_cfdas(DAS &das,
const string & filename,hid_t fileid);
83 extern void read_cfdds(DDS &dds,
const string & filename,hid_t fileid);
109 bool found_key =
false;
111 string key =
"H5.EnableCF";
115 hid_t cf_fileid = -1;
119 if(
true ==found_key ) {
122 if( doset ==
"true" || doset ==
"yes" )
143 cf_fileid = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
146 + filename, __FILE__, __LINE__);
158 + filename, __FILE__, __LINE__);
166 Ancillary::read_ancillary_das( *das, filename ) ;
169 catch(InternalErr & e) {
173 throw BESDapError(e.get_error_message(),
true, e.get_error_code(),
180 throw BESDapError(e.get_error_message(),
false, e.get_error_code(),
187 string s =
"unknown exception caught building HDF5 DAS";
200 string key=
"H5.EnableCF";
207 if( doset ==
"true" || doset ==
"yes" ) {
215 hid_t cf_fileid = -1;
223 cf_fileid = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
226 + filename, __FILE__, __LINE__);
235 +
"Could not open hdf5 file: "
236 + filename, __FILE__, __LINE__);
255 depth_first(fileid, (
char*)
"/", *dds, filename.c_str());
259 if (!dds->check_semantics()) {
261 throw InternalErr(__FILE__, __LINE__,
262 "DDS check_semantics() failed. This can happen when duplicate variable names are defined. ");
265 Ancillary::read_ancillary_dds( *dds, filename ) ;
296 Ancillary::read_ancillary_das( *das, filename ) ;
298 dds->transfer_attributes(das);
304 catch(InternalErr & e) {
308 throw BESDapError(e.get_error_message(),
true, e.get_error_code(),
316 throw BESDapError(e.get_error_message(),
false, e.get_error_code(),
323 string s =
"unknown exception caught building HDF5 DDS";
336 string key=
"H5.EnableCF";
344 if( doset ==
"true" || doset ==
"yes" ) {
354 hid_t cf_fileid = -1;
364 cf_fileid = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
367 + filename, __FILE__, __LINE__);
376 +
"Could not open hdf5 file: "
377 + filename, __FILE__, __LINE__);
381 BESDEBUG(
"h5",
"Building DataDDS without passing file IDs. "<<endl);
399 DataDDS* dds = bdds->
get_dds();
400 dds->filename(filename);
409 depth_first(fileid, (
char*)
"/", *dds, filename.c_str());
412 if (!dds->check_semantics()) {
414 throw InternalErr(__FILE__, __LINE__,
415 "DDS check_semantics() failed. This can happen when duplicate variable names are defined.");
418 Ancillary::read_ancillary_dds( *dds, filename ) ;
442 Ancillary::read_ancillary_das( *das, filename ) ;
444 dds->transfer_attributes(das);
453 catch(InternalErr & e) {
455 throw BESDapError(e.get_error_message(),
true, e.get_error_code(),
459 throw BESDapError(e.get_error_message(),
false, e.get_error_code(),
463 string s =
"unknown exception caught building HDF5 DataDDS";
473 BESDEBUG(
"h5",
"Building DataDDS by passing file IDs. "<<endl);
474 hid_t cf_fileid = -1;
478 cf_fileid = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
481 + filename, __FILE__, __LINE__);
502 if (!hdds->check_semantics()) {
504 throw InternalErr(__FILE__, __LINE__,
505 "DDS check_semantics() failed. This can happen when duplicate variable names are defined.");
508 Ancillary::read_ancillary_dds( *hdds, filename ) ;
514 Ancillary::read_ancillary_das( *das, filename ) ;
516 hdds->transfer_attributes(das);
522 catch(InternalErr & e) {
524 throw BESDapError(e.get_error_message(),
true, e.get_error_code(),
528 throw BESDapError(e.get_error_message(),
false, e.get_error_code(),
532 string s =
"unknown exception caught building HDF5 DataDDS";
546 string key=
"H5.EnableCF";
554 if( doset ==
"true" || doset ==
"yes" ) {
564 hid_t cf_fileid = -1;
572 return hdf5_build_dmr_with_IDs(dhi);
574 cf_fileid = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
577 + filename, __FILE__, __LINE__);
586 +
"Could not open hdf5 file: "
587 + filename, __FILE__, __LINE__);
591 BESDEBUG(
"h5",
"Building DMR without passing file IDs. "<<endl);
593 BaseTypeFactory factory;
594 DDS dds(&factory, name_path(filename),
"3.2");
595 dds.filename(filename);
607 depth_first(fileid, (
char*)
"/", dds, filename.c_str());
610 if (!dds.check_semantics()) {
612 throw InternalErr(__FILE__, __LINE__,
613 "DDS check_semantics() failed. This can happen when duplicate variable names are defined.");
616 Ancillary::read_ancillary_dds( dds, filename ) ;
636 Ancillary::read_ancillary_das( das, filename ) ;
638 dds.transfer_attributes(&das);
645 catch(InternalErr & e) {
647 throw BESDapError(e.get_error_message(),
true, e.get_error_code(),
651 throw BESDapError(e.get_error_message(),
false, e.get_error_code(),
655 string s =
"unknown exception caught building HDF5 DataDDS";
671 D4BaseTypeFactory MyD4TypeFactory;
672 dmr->set_factory(&MyD4TypeFactory);
673 dmr->build_using_dds(dds);
692 BESDEBUG(
"h5",
"Building DMR with passing file IDs. "<<endl);
694 hid_t cf_fileid = -1;
697 cf_fileid = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
700 + filename, __FILE__, __LINE__);
703 BaseTypeFactory factory;
704 DDS dds(&factory, name_path(filename),
"3.2");
705 dds.filename(filename);
715 if (!dds.check_semantics()) {
717 throw InternalErr(__FILE__, __LINE__,
718 "DDS check_semantics() failed. This can happen when duplicate variable names are defined.");
721 Ancillary::read_ancillary_dds( dds, filename ) ;
726 Ancillary::read_ancillary_das( das, filename ) ;
728 dds.transfer_attributes(&das);
735 catch(InternalErr & e) {
737 throw BESDapError(e.get_error_message(),
true, e.get_error_code(),
741 throw BESDapError(e.get_error_message(),
false, e.get_error_code(),
745 string s =
"unknown exception caught building HDF5 DataDDS";
762 D4BaseTypeFactory MyD4TypeFactory;
763 dmr->set_factory(&MyD4TypeFactory);
765 dmr->build_using_dds(dds);
768 HDF5DMR *hdf5_dmr =
new HDF5DMR(dmr);
769 hdf5_dmr->setHDF5Dataset(cf_fileid);
780 hdf5_dmr->set_factory(0);
793 map<string,string> attrs ;
794 attrs[
"name"] = MODULE_NAME ;
795 attrs[
"version"] = MODULE_VERSION ;
800 list<string> services ;
802 if( services.size() > 0 )
805 attrs[
"handles"] = handles ;
823 info->
add_module(MODULE_NAME, MODULE_VERSION);
brief represents simple text information in a response object, such as version and help inforamtion...
error thrown if the resource requested cannot be found
void read_cfdas(DAS &das, const string &filename, hid_t fileid)
#define DAP4DATA_RESPONSE
void set_dds(DataDDS *ddsIn)
Set the response object's DDS.
exception thrown if an internal error is found and is fatal to the BES
static bool hdf5_build_data_with_IDs(BESDataHandlerInterface &dhi)
static bool hdf5_build_data(BESDataHandlerInterface &dhi)
exception thrown if inernal error encountered
string get_symbolic_name() const
retrieve the symbolic name for this container
static string lowercase(const string &s)
Convert a string to all lower case.
Represents an OPeNDAP DDS DAP2 data object within the BES.
virtual void clear_container()
clear the container in the DAP response object
virtual void set_dap4_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
static bool check_beskeys(const string key)
static bool hdf5_build_version(BESDataHandlerInterface &dhi)
static bool hdf5_build_help(BESDataHandlerInterface &dhi)
virtual ~HDF5RequestHandler(void)
static class NCMLUtil overview
virtual string access()=0
returns the true name of this container
virtual void clear_container()
clear the container in the DAP response object
The main header of the HDF5 OPeNDAP handler.
virtual void set_dap4_function(BESDataHandlerInterface &dhi)
set the constraint depending on the context
informational response object
static string implode(const list< string > &values, char delim)
implode a list of values into a single string delimited by delim
virtual BESResponseObject * get_response_object()
return the current response object
static BESServiceRegistry * TheRegistry()
void find_gloattr(hid_t file, DAS &das)
will fill in attributes of the root group into one DAS table.
BESResponseHandler * response_handler
static bool hdf5_build_das(BESDataHandlerInterface &dhi)
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
virtual void begin_tag(const string &tag_name, map< string, string > *attrs=0)
Represents an OPeNDAP DMR DAP4 data object within the BES.
virtual void set_container(const string &cn)
set the container in the DAP response object
error object created from libdap error objects and can handle those errors
include the entry functions to execute the handlers
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
void close_fileid(hid_t fid)
closes HDF5 file reffered by fid.
void depth_first(hid_t pid, const char *gname, DAS &das)
depth first traversal of hdf5 file attributes.
hid_t get_fileid(const char *filename)
gets HDF5 file id.
virtual void clear_container()
clear the container in the DAP response object
Represents a specific data type request handler.
static bool hdf5_build_dds(BESDataHandlerInterface &dhi)
Helper functions for generating DAS attributes and a function to check BES Key.
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
Structure storing information used by the BES to handle the request.
void read_cfdds(DDS &dds, const string &filename, hid_t fileid)
HDF5RequestHandler(const string &name)
This specialization of DDS is used to manage the 'resource' of the open HDF5 dataset handle so that t...
virtual void set_container(const string &cn)
set the container in the DAP response object
virtual bool add_handler(const string &handler_name, p_request_handler handler_method)
add a handler method to the request handler that knows how to fill in a specific response object ...
Represents an OPeNDAP DAS DAP2 data object within the BES.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
void setHDF5Dataset(const hid_t fileid_in)
Helper functions to generate DDS/DAS/DODS for the default option.
static BESKeys * TheKeys()
virtual void set_container(const string &cn)
set the container in the DAP response object
virtual void add_module(const string &n, const string &v)
Abstract base class representing a specific set of information in response to a request to the BES...
BESContainer * container
pointer to current container in this interface
virtual void end_tag(const string &tag_name)
virtual void services_handled(const string &handler, list< string > &services)
returns the list of servies provided by the handler in question