bes  Updated for version 3.20.6
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 using std::ostream;
35 using std::string;
36 
37 #include "FoCovJsonModule.h"
38 #include "FoDapCovJsonTransmitter.h"
39 #include "FoCovJsonRequestHandler.h"
40 #include "BESRequestHandlerList.h"
41 
42 #include <BESReturnManager.h>
43 
44 #include <BESServiceRegistry.h>
45 #include <BESDapNames.h>
46 
47 #include <TheBESKeys.h>
48 #include <BESDebug.h>
49 
50 #define RETURNAS_COVJSON "covjson"
51 #define RETURNAS_ICOVJSON "covjson"
52 
53 
64 void FoCovJsonModule::initialize(const string &modname)
65 {
66  BESDEBUG( "focovjson", "Initializing module " << modname << endl );
67 
68  BESRequestHandler *handler = new FoCovJsonRequestHandler(modname);
69  BESRequestHandlerList::TheList()->add_handler(modname, handler);
70 
71 
72  BESDEBUG( "focovjson", " adding " << RETURNAS_COVJSON << " transmitter" << endl );
73  BESReturnManager::TheManager()->add_transmitter(RETURNAS_COVJSON, new FoDapCovJsonTransmitter());
74 
75 
76  BESDebug::Register("focovjson");
77  BESDEBUG( "focovjson", "Done Initializing module " << modname << endl );
78 }
79 
88 void FoCovJsonModule::terminate(const string &modname)
89 {
90  BESDEBUG( "focovjson", "Cleaning module " << modname << endl );
91  BESDEBUG( "focovjson", " removing " << RETURNAS_COVJSON << " transmitter" << endl );
92 
93  BESReturnManager::TheManager()->del_transmitter(RETURNAS_COVJSON);
94 
95  BESDEBUG( "focovjson", " removing " << modname << " request handler " << endl );
96 
97  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
98  if (rh)
99  delete rh;
100 
101  BESDEBUG( "focovjson", "Done Cleaning module " << modname << endl );
102 }
103 
110 void FoCovJsonModule::dump(ostream &strm) const
111 {
112  strm << BESIndent::LMarg << "FoCovJsonModule::dump - (" << (void *) this << ")" << endl;
113 }
114 
118 extern "C"
119 BESAbstractModule *maker()
120 {
121  return new FoCovJsonModule;
122 }
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
BESAbstractModule
Definition: BESAbstractModule.h:40
FoCovJsonModule::initialize
virtual void initialize(const std::string &modname)
initialize the module by adding call backs and registering objects with the framework
Definition: FoCovJsonModule.cc:64
FoCovJsonModule::terminate
virtual void terminate(const std::string &modname)
removes any registered callbacks or objects from the framework
Definition: FoCovJsonModule.cc:88
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
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
FoCovJsonModule::dump
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
Definition: FoCovJsonModule.cc:110