bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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#include <dispatch/BESRequestHandlerList.h>
32#include <dispatch/BESContainerStorageList.h>
33#include <dispatch/BESFileContainerStorage.h>
34#include <dispatch/BESCatalogDirectory.h>
35#include <dispatch/BESCatalogList.h>
36#include <dispatch/BESReturnManager.h>
37#include <dispatch/BESServiceRegistry.h>
38#include <dispatch/BESDebug.h>
39
40#include <dap/BESDapNames.h>
41#include <dap/BESDapService.h>
42
43#include "GDALModule.h"
44#include "GDALRequestHandler.h"
45#include "writer/GeoTiffTransmitter.h"
46#include "writer/JPEG2000Transmitter.h"
47
48#define GDAL_CATALOG "catalog"
49#define RETURNAS_GEOTIFF "geotiff"
50#define RETURNAS_JPEG2000 "jpeg2000"
51
52#define JP2 1
53
54using namespace std;
55
56void GDALModule::initialize(const string & modname)
57{
58 BESDEBUG("gdal", "Initializing GDAL module " << modname << endl);
59
60 BESRequestHandler *handler = new GDALRequestHandler(modname);
61 BESRequestHandlerList::TheList()->add_handler(modname, handler);
62
63 // This part if the module responds to requests for DMR, DAP, etc., responses.
64
66
67 if (!BESCatalogList::TheCatalogList()->ref_catalog(GDAL_CATALOG)) {
68 BESCatalogList::TheCatalogList()-> add_catalog(new BESCatalogDirectory(GDAL_CATALOG));
69 }
70
71 if (!BESContainerStorageList::TheList()->ref_persistence(GDAL_CATALOG)) {
72 BESFileContainerStorage *csc = new BESFileContainerStorage(GDAL_CATALOG);
73 BESContainerStorageList::TheList()->add_persistence(csc);
74 }
75
76 // This part of the handler sets up transmitters that return geotiff and jp2000 responses
77 BESReturnManager::TheManager()->add_transmitter(RETURNAS_GEOTIFF, new GeoTiffTransmitter());
78 BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, RETURNAS_GEOTIFF);
79
80#if JP2
81 BESReturnManager::TheManager()->add_transmitter(RETURNAS_JPEG2000, new JPEG2000Transmitter());
82 BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, RETURNAS_JPEG2000);
83#endif
84
85 BESDebug::Register("gdal");
86
87 BESDEBUG("gdal", "Done Initializing GDAL module " << modname << endl);
88}
89
90void GDALModule::terminate(const string & modname)
91{
92 BESDEBUG("gdal", "Cleaning GDAL module " << modname << endl);
93
94 BESContainerStorageList::TheList()->deref_persistence(GDAL_CATALOG);
95
96 BESCatalogList::TheCatalogList()->deref_catalog(GDAL_CATALOG);
97
98 BESReturnManager::TheManager()->del_transmitter(RETURNAS_GEOTIFF);
99#if JP2
100 BESReturnManager::TheManager()->del_transmitter(RETURNAS_JPEG2000);
101#endif
102
103 delete BESRequestHandlerList::TheList()->remove_handler(modname);
104
105 BESDEBUG("gdal", "Done Cleaning GDAL module " << modname << endl);
106}
107
114void GDALModule::dump(ostream & strm) const
115{
116 strm << BESIndent::LMarg << "GDALModule::dump - (" << (void *) this << ")" << endl;
117}
118
119extern "C" BESAbstractModule * maker()
120{
121 return new GDALModule;
122}
123
static void handle_dap_service(const std::string &handler)
static function to register a handler to handle the dap services
static void Register(const std::string &flagName)
register the specified debug flag
Definition BESDebug.h:126
virtual void add_format(const std::string &service, const std::string &cmd, const std::string &format)
add a format response to a command of a service
virtual void dump(std::ostream &strm) const
dumps information about this object