bes  Updated for version 3.20.5
GDALModule.cc
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>
38 #include <BESContainerStorageList.h>
39 #include <BESFileContainerStorage.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 
50  BESRequestHandler *handler = new GDALRequestHandler(modname);
51  BESRequestHandlerList::TheList()->add_handler(modname, handler);
52 
54 
55  if (!BESCatalogList::TheCatalogList()->ref_catalog(GDAL_CATALOG)) {
56  BESCatalogList::TheCatalogList()-> add_catalog(new BESCatalogDirectory(GDAL_CATALOG));
57  }
58 
59  if (!BESContainerStorageList::TheList()->ref_persistence(GDAL_CATALOG)) {
60  BESFileContainerStorage *csc = new BESFileContainerStorage(GDAL_CATALOG);
61  BESContainerStorageList::TheList()->add_persistence(csc);
62  }
63 
64  BESDebug::Register("gdal");
65 
66  BESDEBUG("gdal", "Done Initializing GDAL module " << modname << endl);
67 }
68 
69 void GDALModule::terminate(const string & modname)
70 {
71  BESDEBUG("gdal", "Cleaning GDAL module " << modname << endl);
72 
73  delete BESRequestHandlerList::TheList()->remove_handler(modname);
74 
75  BESContainerStorageList::TheList()->deref_persistence(GDAL_CATALOG);
76 
77  BESCatalogList::TheCatalogList()->deref_catalog(GDAL_CATALOG);
78 
79  BESDEBUG("gdal", "Done Cleaning GDAL module " << modname << endl);
80 }
81 
88 void GDALModule::dump(ostream & strm) const
89 {
90  strm << BESIndent::LMarg << "GDALModule::dump - (" << (void *) this << ")" << endl;
91 }
92 
93 extern "C" BESAbstractModule * maker()
94 {
95  return new GDALModule;
96 }
97 
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
virtual bool add_handler(const std::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.
Catalogs from a directory structure.
virtual void dump(ostream &strm) const
dumps information about this object
Definition: GDALModule.cc:88
Represents a specific data type request handler.
implementation of BESContainerStorage that represents a data within a catalog repository
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
static void handle_dap_service(const string &handler)
static function to register a handler to handle the dap services