bes  Updated for version 3.20.5
FoCovJsonModule.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // FoCovJsonModule.cc
4 //
5 // This file is part of BES CovJSON File Out Module
6 //
7 // Copyright (c) 2018 OPeNDAP, Inc.
8 // Author: Corey Hemphill <hemphilc@oregonstate.edu>
9 // Author: River Hendriksen <hendriri@oregonstate.edu>
10 // Author: Riley Rimer <rrimer@oregonstate.edu>
11 //
12 // Adapted from the File Out JSON module implemented by Nathan Potter
13 //
14 // This library is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU Lesser General Public
16 // License as published by the Free Software Foundation; either
17 // version 2.1 of the License, or (at your option) any later version.
18 //
19 // This library is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 // Lesser General Public License for more details.
23 //
24 // You should have received a copy of the GNU Lesser General Public
25 // License along with this library; if not, write to the Free Software
26 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 //
28 
29 #include "config.h"
30 
31 #include <iostream>
32 
33 using std::endl;
34 
35 #include "FoCovJsonModule.h"
36 #include "FoDapCovJsonTransmitter.h"
37 #include "FoCovJsonRequestHandler.h"
38 #include "BESRequestHandlerList.h"
39 
40 #include <BESReturnManager.h>
41 
42 #include <BESServiceRegistry.h>
43 #include <BESDapNames.h>
44 
45 #include <TheBESKeys.h>
46 #include <BESDebug.h>
47 
48 #define RETURNAS_COVJSON "covjson"
49 #define RETURNAS_ICOVJSON "covjson"
50 
51 
62 void FoCovJsonModule::initialize(const string &modname)
63 {
64  BESDEBUG( "focovjson", "Initializing module " << modname << endl );
65 
66  BESRequestHandler *handler = new FoCovJsonRequestHandler(modname);
67  BESRequestHandlerList::TheList()->add_handler(modname, handler);
68 
69 
70  BESDEBUG( "focovjson", " adding " << RETURNAS_COVJSON << " transmitter" << endl );
71  BESReturnManager::TheManager()->add_transmitter(RETURNAS_COVJSON, new FoDapCovJsonTransmitter());
72 
73 
74  BESDebug::Register("focovjson");
75  BESDEBUG( "focovjson", "Done Initializing module " << modname << endl );
76 }
77 
86 void FoCovJsonModule::terminate(const string &modname)
87 {
88  BESDEBUG( "focovjson", "Cleaning module " << modname << endl );
89  BESDEBUG( "focovjson", " removing " << RETURNAS_COVJSON << " transmitter" << endl );
90 
91  BESReturnManager::TheManager()->del_transmitter(RETURNAS_COVJSON);
92 
93  BESDEBUG( "focovjson", " removing " << modname << " request handler " << endl );
94 
95  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
96  if (rh)
97  delete rh;
98 
99  BESDEBUG( "focovjson", "Done Cleaning module " << modname << endl );
100 }
101 
108 void FoCovJsonModule::dump(ostream &strm) const
109 {
110  strm << BESIndent::LMarg << "FoCovJsonModule::dump - (" << (void *) this << ")" << endl;
111 }
112 
116 extern "C"
117 BESAbstractModule *maker()
118 {
119  return new FoCovJsonModule;
120 }
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:77
BESRequestHandlerList::remove_handler
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Definition: BESRequestHandlerList.cc:72
BESAbstractModule
Definition: BESAbstractModule.h:42
FoCovJsonModule::initialize
virtual void initialize(const string &modname)
initialize the module by adding call backs and registering objects with the framework
Definition: FoCovJsonModule.cc:62
FoCovJsonModule::terminate
virtual void terminate(const string &modname)
removes any registered callbacks or objects from the framework
Definition: FoCovJsonModule.cc:86
FoCovJsonModule::dump
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
Definition: FoCovJsonModule.cc:108
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:50
BESDebug::Register
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
FoCovJsonModule
Module that allows for OPeNDAP Data objects to be returned as geotiff files.
Definition: FoCovJsonModule.h:50
FoDapCovJsonTransmitter
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
Definition: FoDapCovJsonTransmitter.h:46
FoCovJsonRequestHandler
A Request Handler for the Fileout NetCDF request.
Definition: FoCovJsonRequestHandler.h:41