bes  Updated for version 3.20.5
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 
29 using std::endl;
30 
31 #include "FONgModule.h"
32 #include "GeoTiffTransmitter.h"
33 #include "JPEG2000Transmitter.h"
34 #include "FONgRequestHandler.h"
35 #include "BESRequestHandlerList.h"
36 
37 #include <BESReturnManager.h>
38 
39 #include <BESServiceRegistry.h>
40 #include <BESDapNames.h>
41 
42 #include <TheBESKeys.h>
43 #include <BESDebug.h>
44 
45 #define RETURNAS_GEOTIFF "geotiff"
46 #define RETURNAS_JPEG2000 "jpeg2000"
47 
48 #define JP2 1
49 
50 
61 void FONgModule::initialize(const string &modname)
62 {
63  BESDEBUG( "fong", "Initializing module " << modname << endl );
64 
65  BESRequestHandler *handler = new FONgRequestHandler(modname);
66  BESRequestHandlerList::TheList()->add_handler(modname, handler);
67 
68  BESDEBUG( "fong", " adding " << RETURNAS_GEOTIFF << " transmitter" << endl );
69  BESReturnManager::TheManager()->add_transmitter(RETURNAS_GEOTIFF, new GeoTiffTransmitter());
70 
71 #if JP2
72  BESDEBUG( "fong", " adding " << RETURNAS_JPEG2000 << " transmitter" << endl );
73  BESReturnManager::TheManager()->add_transmitter(RETURNAS_JPEG2000, new JPEG2000Transmitter());
74 #endif
75 
76  BESDEBUG( "fong", " adding geotiff service to dap" << endl );
77  BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, RETURNAS_GEOTIFF);
78 
79 #if JP2
80  BESDEBUG( "fong", " adding jpeg2000 service to dap" << endl );
81  BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, RETURNAS_JPEG2000);
82 #endif
83 
84  BESDebug::Register("fong");
85  BESDEBUG( "fong", "Done Initializing module " << modname << endl );
86 }
87 
96 void FONgModule::terminate(const string &modname)
97 {
98  BESDEBUG( "fong", "Cleaning module " << modname << endl );
99  BESDEBUG( "fong", " removing " << RETURNAS_GEOTIFF << " transmitter" << endl );
100 
101  BESReturnManager::TheManager()->del_transmitter(RETURNAS_GEOTIFF);
102 
103 #if JP2
104  BESDEBUG( "fong", " removing " << RETURNAS_JPEG2000 << " transmitter" << endl );
105  BESReturnManager::TheManager()->del_transmitter(RETURNAS_JPEG2000);
106 #endif
107 
108  BESDEBUG( "fong", " removing " << modname << " request handler " << endl );
109 
110  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
111  if (rh)
112  delete rh;
113 
114  BESDEBUG( "fong", "Done Cleaning module " << modname << endl );
115 }
116 
123 void FONgModule::dump(ostream &strm) const
124 {
125  strm << BESIndent::LMarg << "FONgModule::dump - (" << (void *) this << ")" << endl;
126 }
127 
131 extern "C"
132 BESAbstractModule *maker()
133 {
134  return new FONgModule;
135 }
136 
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
virtual bool add_handler(const std::string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
BESTransmitter class named "geotiff" that transmits an OPeNDAP data object as a geotiff file.
A Request Handler for the Fileout GDAL request.
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
Definition: FONgModule.cc:123
virtual void add_format(const string &service, const string &cmd, const string &format)
add a format response to a command of a service
Represents a specific data type request handler.
virtual void terminate(const string &modname)
removes any registered callbacks or objects from the framework
Definition: FONgModule.cc:96
Module that allows for OPeNDAP Data objects to be returned as geotiff files.
Definition: FONgModule.h:46
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
virtual void initialize(const string &modname)
initialize the module by adding call backs and registering objects with the framework
Definition: FONgModule.cc:61
BESTransmitter class named "geotiff" that transmits an OPeNDAP data object as a geotiff file.