OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HDF4Module.cc
Go to the documentation of this file.
1 // HDF4Module.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 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 
32 #include <iostream>
33 
34 using std::endl;
35 
36 #include "HDF4Module.h"
37 #include <BESRequestHandlerList.h>
38 #include "HDF4RequestHandler.h"
39 #include <BESDapService.h>
42 #include <BESCatalogDirectory.h>
43 #include <BESCatalogList.h>
44 #include <BESDebug.h>
45 
46 #define HDF4_CATALOG "catalog"
47 
48 void
49  HDF4Module::initialize(const string & modname)
50 {
51  BESDEBUG("h4", "Initializing HDF4 module " << modname << endl) ;
52 
53  BESDEBUG("h4",
54  " adding " << modname << " request handler" << endl) ;
55  BESRequestHandler *handler = new HDF4RequestHandler(modname);
56  BESRequestHandlerList::TheList()->add_handler(modname, handler);
57 
58  BESDEBUG( "h4", modname << " handles dap services" << endl ) ;
60 
61  BESDEBUG("h4", " adding " << HDF4_CATALOG << " catalog" << endl) ;
62  if( !BESCatalogList::TheCatalogList()->ref_catalog( HDF4_CATALOG ) )
63  {
65  add_catalog(new BESCatalogDirectory(HDF4_CATALOG));
66  }
67  else
68  {
69  BESDEBUG( "h4", " catalog already exists, skipping" << endl ) ;
70  }
71 
72  BESDEBUG("h4",
73  " adding catalog container storage" << HDF4_CATALOG <<
74  endl) ;
75  if( !BESContainerStorageList::TheList()->ref_persistence( HDF4_CATALOG ) )
76  {
80  }
81  else
82  {
83  BESDEBUG( "h4", " storage already exists, skipping" << endl ) ;
84  }
85 
86  BESDEBUG("h4", " adding h4 debug context" << endl) ;
87  BESDebug::Register("h4");
88 
89  BESDEBUG("h4", "Done Initializing HDF4 module " << modname << endl) ;
90 }
91 
92 void HDF4Module::terminate(const string & modname)
93 {
94  BESDEBUG("h4", "Cleaning HDF4 module " << modname << endl) ;
95 
96  BESDEBUG("h4", " removing HDF4 Handler" << modname << endl) ;
97  BESRequestHandler *rh =
99  if (rh)
100  delete rh;
101 
102  BESDEBUG("h4", " removing catalog container storage" << HDF4_CATALOG
103  << endl) ;
105 
106  BESDEBUG("h4", " removing " << HDF4_CATALOG << " catalog" << endl) ;
108 
109  BESDEBUG("h4", "Done Cleaning HDF4 module " << modname << endl) ;
110 }
111 
118 void HDF4Module::dump(ostream & strm) const
119 {
120  strm << BESIndent::LMarg << "HDF4Module::dump - ("
121  << (void *) this << ")" << endl;
122 }
123 
124 extern "C" {
126  return new HDF4Module;
127 }}
virtual void terminate(const string &modname)
Definition: HDF4Module.cc:92
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: HDF4Module.cc:125
#define HDF4_CATALOG
Definition: HDF4Module.cc:46
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 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.
Represents a specific data type request handler.
static BESRequestHandlerList * TheList()
static BESContainerStorageList * TheList()
virtual void dump(ostream &strm) const
dumps information about this object
Definition: HDF4Module.cc:118
virtual void initialize(const string &modname)
Definition: HDF4Module.cc:49
#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