OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HDF5Module.cc
Go to the documentation of this file.
1 // HDF5Module.cc
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004,2005 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
33 
34 
35 #include <iostream>
36 
37 using std::endl;
38 
39 #include "HDF5Module.h"
40 #include <BESRequestHandlerList.h>
41 #include "HDF5RequestHandler.h"
42 #include <BESDapService.h>
45 #include <BESCatalogDirectory.h>
46 #include <BESCatalogList.h>
47 #include <BESDebug.h>
48 
49 #define HDF5_CATALOG "catalog"
50 
51 void
52  HDF5Module::initialize(const string & modname)
53 {
54  BESDEBUG("h5", "Initializing HDF5 module " << modname << endl) ;
55 
56  BESDEBUG("h5",
57  " adding " << modname << " request handler" << endl) ;
58  BESRequestHandler *handler = new HDF5RequestHandler(modname);
59  BESRequestHandlerList::TheList()->add_handler(modname, handler);
60 
61  BESDEBUG( "h5", modname << " handles dap services" << endl ) ;
63 
64  BESDEBUG("h5", " adding " << HDF5_CATALOG << " catalog" << endl) ;
65  if( !BESCatalogList::TheCatalogList()->ref_catalog( HDF5_CATALOG ) )
66  {
68  add_catalog(new BESCatalogDirectory(HDF5_CATALOG));
69  }
70  else
71  {
72  BESDEBUG( "h5", " catalog already exists, skipping" << endl ) ;
73  }
74 
75  BESDEBUG("h5", " adding catalog container storage " << HDF5_CATALOG
76  << endl) ;
77  if( !BESContainerStorageList::TheList()->ref_persistence( HDF5_CATALOG ) )
78  {
82  }
83  else
84  {
85  BESDEBUG( "h5", " storage already exists, skipping" << endl ) ;
86  }
87 
88  BESDEBUG("h5", " adding h5 debug context" << endl) ;
89  BESDebug::Register("h5");
90 
91  BESDEBUG("h5", "Done Initializing HDF5 " << modname << endl) ;
92 }
93 
94 void HDF5Module::terminate(const string & modname)
95 {
96  BESDEBUG("h5", "Cleaning HDF5 module " << modname << endl) ;
97 
98  BESDEBUG("h5",
99  " removing " << modname << " request handler" << endl) ;
100  BESRequestHandler *rh =
102  if (rh)
103  delete rh;
104 
105  BESDEBUG("h5",
106  " removing catalog container storage " << HDF5_CATALOG <<
107  endl) ;
109 
110  BESDEBUG("h5", " removing " << HDF5_CATALOG << " catalog" << endl) ;
112 
113  BESDEBUG("h5", "Done Cleaning HDF5 module " << modname << endl) ;
114 }
115 
122 void HDF5Module::dump(ostream & strm) const
123 {
124  strm << BESIndent::LMarg << "HDF5Module::dump - ("
125  << (void *) this << ")" << endl;
126 }
127 
128 extern "C" {
130  return new HDF5Module;
131 }}
virtual bool add_handler(const string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
BESAbstractModule * maker()
Definition: HDF5Module.cc:129
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
implementation of BESContainerStorage that represents a data within a catalog repository ...
virtual void terminate(const string &modname)
Definition: HDF5Module.cc:94
The starting and ending fuctions for the HDF5 OPeNDAP handler via BES.
virtual void dump(ostream &strm) const
dumps information about this object
Definition: HDF5Module.cc:122
virtual bool deref_catalog(const string &catalog_name)
de-reference the specified catalog and remove from list if no longer referenced
builds catalogs from a directory structure
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
virtual bool deref_persistence(const string &persist_name)
dereference a persistent store in the list.
include the entry functions to execute the handlers
Represents a specific data type request handler.
#define HDF5_CATALOG
Definition: HDF5Module.cc:49
static BESRequestHandlerList * TheList()
virtual void initialize(const string &modname)
Definition: HDF5Module.cc:52
static BESContainerStorageList * TheList()
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
static BESCatalogList * TheCatalogList()
returns the singleton BESCatalogList instance.
static void Register(const string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
static void handle_dap_service(const string &handler)
static function to register a handler to handle the dap services
virtual BESRequestHandler * remove_handler(const string &handler_name)
remove and return the specified request handler