bes  Updated for version 3.20.6
FoJsonModule.cc
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // FoJsonModule.cc
5 
6 // This file is part of BES JSON File Out Module
7 
8 // Copyright (c) 2014 OPeNDAP, Inc.
9 // Author: Nathan Potter <ndp@opendap.org>
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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
26 // (c) COPYRIGHT URI/MIT 1995-1999
27 // Please read the full copyright statement in the file COPYRIGHT_URI.
28 //
29 
30 #include "config.h"
31 
32 #include <iostream>
33 
34 using std::endl;
35 using std::ostream;
36 using std::string;
37 
38 #include "FoJsonModule.h"
39 #include "FoDapJsonTransmitter.h"
40 #include "FoInstanceJsonTransmitter.h"
41 #include "FoJsonRequestHandler.h"
42 #include "BESRequestHandlerList.h"
43 
44 #include <BESReturnManager.h>
45 
46 #include <BESServiceRegistry.h>
47 #include <BESDapNames.h>
48 
49 #include <TheBESKeys.h>
50 #include <BESDebug.h>
51 
52 #define RETURNAS_JSON "json"
53 #define RETURNAS_IJSON "ijson"
54 
55 
56 
67 void FoJsonModule::initialize(const string &modname)
68 {
69  BESDEBUG( "fojson", "Initializing module " << modname << endl );
70 
71  BESRequestHandler *handler = new FoJsonRequestHandler(modname);
72  BESRequestHandlerList::TheList()->add_handler(modname, handler);
73 
74 
75  BESDEBUG( "fojson", " adding " << RETURNAS_JSON << " transmitter" << endl );
76  BESReturnManager::TheManager()->add_transmitter(RETURNAS_JSON, new FoDapJsonTransmitter());
77 
78 
79  BESDEBUG( "fojson", " adding " << RETURNAS_IJSON << " transmitter" << endl );
80  BESReturnManager::TheManager()->add_transmitter(RETURNAS_IJSON, new FoInstanceJsonTransmitter());
81 
82 
83  BESDebug::Register("fojson");
84  BESDEBUG( "fojson", "Done Initializing module " << modname << endl );
85 }
86 
95 void FoJsonModule::terminate(const string &modname)
96 {
97  BESDEBUG( "fojson", "Cleaning module " << modname << endl );
98  BESDEBUG( "fojson", " removing " << RETURNAS_JSON << " transmitter" << endl );
99 
100  BESReturnManager::TheManager()->del_transmitter(RETURNAS_JSON);
101 
102  BESDEBUG( "fojson", " removing " << modname << " request handler " << endl );
103 
104  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
105  if (rh)
106  delete rh;
107 
108  BESDEBUG( "fojson", "Done Cleaning module " << modname << endl );
109 }
110 
117 void FoJsonModule::dump(ostream &strm) const
118 {
119  strm << BESIndent::LMarg << "FoJsonModule::dump - (" << (void *) this << ")" << endl;
120 }
121 
125 extern "C"
126 BESAbstractModule *maker()
127 {
128  return new FoJsonModule;
129 }
130 
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
FoJsonModule::initialize
virtual void initialize(const std::string &modname)
initialize the module by adding call backs and registering objects with the framework
Definition: FoJsonModule.cc:67
BESAbstractModule
Definition: BESAbstractModule.h:40
FoInstanceJsonTransmitter
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
Definition: FoInstanceJsonTransmitter.h:46
FoJsonModule::dump
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
Definition: FoJsonModule.cc:117
FoJsonModule
Module that allows for OPeNDAP Data objects to be returned as geotiff files.
Definition: FoJsonModule.h:51
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
FoJsonRequestHandler
A Request Handler for the Fileout NetCDF request.
Definition: FoJsonRequestHandler.h:41
FoJsonModule::terminate
virtual void terminate(const std::string &modname)
removes any registered callbacks or objects from the framework
Definition: FoJsonModule.cc:95
FoDapJsonTransmitter
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
Definition: FoDapJsonTransmitter.h:46