bes Updated for version 3.20.10
FONgModule.cc
1// FONgModule.cc
2
3// This file is part of BES GDAL File Out Module
4
5// Copyright (c) 2012 OPeNDAP, Inc.
6// Author: James Gallagher <jgallagher@opendap.org>
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public
10// License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Lesser General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// You can contact University Corporation for Atmospheric Research at
23// 3080 Center Green Drive, Boulder, CO 80301
24
25#include "config.h"
26
27#include <iostream>
28
29using std::endl;
30using std::ostream;
31using std::string;
32
33#include "FONgModule.h"
34#include "GeoTiffTransmitter.h"
35#include "JPEG2000Transmitter.h"
36#include "FONgRequestHandler.h"
37#include "BESRequestHandlerList.h"
38
39#include <BESReturnManager.h>
40
41#include <BESServiceRegistry.h>
42#include <BESDapNames.h>
43
44#include <TheBESKeys.h>
45#include <BESDebug.h>
46
47#define RETURNAS_GEOTIFF "geotiff"
48#define RETURNAS_JPEG2000 "jpeg2000"
49
50#define JP2 1
51
52
63void FONgModule::initialize(const string &modname)
64{
65 BESDEBUG( "fong", "Initializing module " << modname << endl );
66
67 BESRequestHandler *handler = new FONgRequestHandler(modname);
68 BESRequestHandlerList::TheList()->add_handler(modname, handler);
69
70 BESDEBUG( "fong", " adding " << RETURNAS_GEOTIFF << " transmitter" << endl );
71 BESReturnManager::TheManager()->add_transmitter(RETURNAS_GEOTIFF, new GeoTiffTransmitter());
72
73#if JP2
74 BESDEBUG( "fong", " adding " << RETURNAS_JPEG2000 << " transmitter" << endl );
75 BESReturnManager::TheManager()->add_transmitter(RETURNAS_JPEG2000, new JPEG2000Transmitter());
76#endif
77
78 BESDEBUG( "fong", " adding geotiff service to dap" << endl );
79 BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, RETURNAS_GEOTIFF);
80
81#if JP2
82 BESDEBUG( "fong", " adding jpeg2000 service to dap" << endl );
83 BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, RETURNAS_JPEG2000);
84#endif
85
86 BESDebug::Register("fong");
87 BESDEBUG( "fong", "Done Initializing module " << modname << endl );
88}
89
98void FONgModule::terminate(const string &modname)
99{
100 BESDEBUG( "fong", "Cleaning module " << modname << endl );
101 BESDEBUG( "fong", " removing " << RETURNAS_GEOTIFF << " transmitter" << endl );
102
103 BESReturnManager::TheManager()->del_transmitter(RETURNAS_GEOTIFF);
104
105#if JP2
106 BESDEBUG( "fong", " removing " << RETURNAS_JPEG2000 << " transmitter" << endl );
107 BESReturnManager::TheManager()->del_transmitter(RETURNAS_JPEG2000);
108#endif
109
110 BESDEBUG( "fong", " removing " << modname << " request handler " << endl );
111
112 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
113 if (rh)
114 delete rh;
115
116 BESDEBUG( "fong", "Done Cleaning module " << modname << endl );
117}
118
125void FONgModule::dump(ostream &strm) const
126{
127 strm << BESIndent::LMarg << "FONgModule::dump - (" << (void *) this << ")" << endl;
128}
129
133extern "C"
134BESAbstractModule *maker()
135{
136 return new FONgModule;
137}
138
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:149
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 BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Represents a specific data type request handler.
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
Module that allows for OPeNDAP Data objects to be returned as geotiff files.
Definition: FONgModule.h:47
virtual void initialize(const std::string &modname)
initialize the module by adding call backs and registering objects with the framework
Definition: FONgModule.cc:63
virtual void terminate(const std::string &modname)
removes any registered callbacks or objects from the framework
Definition: FONgModule.cc:98
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
Definition: FONgModule.cc:125
A Request Handler for the Fileout GDAL request.
BESTransmitter class named "geotiff" that transmits an OPeNDAP data object as a geotiff file.
BESTransmitter class named "geotiff" that transmits an OPeNDAP data object as a geotiff file.