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