OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
GDALModule.cc
Go to the documentation of this file.
1 // GDALModule.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 // This file is part of the GDAL OPeNDAP Adapter
7 
8 // Copyright (c) 2004 OPeNDAP, Igdal.
9 // Author: Frank Warmerdam <warmerdam@pobox.com>
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Igdal., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // You can contact OPeNDAP, Igdal. at PO Box 112, Saunderstown, RI. 02874-0112.
26 
27 #include "config.h"
28 
29 #include <iostream>
30 
31 using std::endl;
32 
33 #include "GDALModule.h"
34 
35 #include <BESRequestHandlerList.h>
36 #include "GDALRequestHandler.h"
37 #include <BESDapService.h>
40 #include <BESCatalogDirectory.h>
41 #include <BESCatalogList.h>
42 #include <BESDebug.h>
43 
44 #define GDAL_CATALOG "catalog"
45 
46 void GDALModule::initialize(const string & modname)
47 {
48  BESDEBUG("gdal", "Initializing GDAL module " << modname << endl);
49  BESDEBUG("gdal", " adding " << modname << " request handler" << endl);
50 
51  BESRequestHandler *handler = new GDALRequestHandler(modname);
52  BESRequestHandlerList::TheList()->add_handler(modname, handler);
53 
54  BESDEBUG("gdal", modname << " handles dap services" << endl);
55 
57 
58  BESDEBUG("gdal", " adding " << GDAL_CATALOG << " catalog" << endl);
59 
60  if (!BESCatalogList::TheCatalogList()->ref_catalog(GDAL_CATALOG)) {
62  }
63  else {
64  BESDEBUG("gdal", " catalog already exists, skipping" << endl);
65  }
66 
67  BESDEBUG("gdal", " adding catalog container storage " << GDAL_CATALOG << endl);
68 
69  if (!BESContainerStorageList::TheList()->ref_persistence(GDAL_CATALOG)) {
72  }
73  else {
74  BESDEBUG("gdal", " storage already exists, skipping" << endl);
75  }
76 
77  BESDEBUG("gdal", " adding gdal debug context" << endl);
78  BESDebug::Register("gdal");
79 
80  BESDEBUG("gdal", "Done Initializing GDAL module " << modname << endl);
81 }
82 
83 void GDALModule::terminate(const string & modname)
84 {
85  BESDEBUG("gdal", "Cleaning GDAL module " << modname << endl);
86 
87  BESDEBUG("gdal", " removing GDAL Handler" << modname << endl);
89  if (rh)
90  delete rh;
91 
92  BESDEBUG("gdal", " removing catalog container storage" << GDAL_CATALOG << endl);
94 
95  BESDEBUG("gdal", " removing " << GDAL_CATALOG << " catalog" << endl);
97 
98  BESDEBUG("gdal", "Done Cleaning GDAL module " << modname << endl);
99 }
100 
107 void GDALModule::dump(ostream & strm) const
108 {
109  strm << BESIndent::LMarg << "GDALModule::dump - (" << (void *) this << ")" << endl;
110 }
111 
112 extern "C" BESAbstractModule * maker()
113 {
114  return new GDALModule;
115 }
116 
virtual bool add_handler(const string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
virtual void terminate(const string &modname)
Definition: GDALModule.cc:83
implementation of BESContainerStorage that represents a data within a catalog repository ...
#define GDAL_CATALOG
Definition: GDALModule.cc:44
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.
virtual void dump(ostream &strm) const
dumps information about this object
Definition: GDALModule.cc:107
Represents a specific data type request handler.
static BESRequestHandlerList * TheList()
static BESContainerStorageList * TheList()
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
virtual void initialize(const string &modname)
Definition: GDALModule.cc:46
static BESCatalogList * TheCatalogList()
returns the singleton BESCatalogList instance.
static void Register(const string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
BESAbstractModule * maker()
Definition: GDALModule.cc:112
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