bes  Updated for version 3.20.5
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 
36 #include "FoJsonModule.h"
37 #include "FoDapJsonTransmitter.h"
38 #include "FoInstanceJsonTransmitter.h"
39 #include "FoJsonRequestHandler.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_JSON "json"
51 #define RETURNAS_IJSON "ijson"
52 
53 
54 
65 void FoJsonModule::initialize(const string &modname)
66 {
67  BESDEBUG( "fojson", "Initializing module " << modname << endl );
68 
69  BESRequestHandler *handler = new FoJsonRequestHandler(modname);
70  BESRequestHandlerList::TheList()->add_handler(modname, handler);
71 
72 
73  BESDEBUG( "fojson", " adding " << RETURNAS_JSON << " transmitter" << endl );
74  BESReturnManager::TheManager()->add_transmitter(RETURNAS_JSON, new FoDapJsonTransmitter());
75 
76 
77  BESDEBUG( "fojson", " adding " << RETURNAS_IJSON << " transmitter" << endl );
78  BESReturnManager::TheManager()->add_transmitter(RETURNAS_IJSON, new FoInstanceJsonTransmitter());
79 
80 
81  BESDebug::Register("fojson");
82  BESDEBUG( "fojson", "Done Initializing module " << modname << endl );
83 }
84 
93 void FoJsonModule::terminate(const string &modname)
94 {
95  BESDEBUG( "fojson", "Cleaning module " << modname << endl );
96  BESDEBUG( "fojson", " removing " << RETURNAS_JSON << " transmitter" << endl );
97 
98  BESReturnManager::TheManager()->del_transmitter(RETURNAS_JSON);
99 
100  BESDEBUG( "fojson", " removing " << modname << " request handler " << endl );
101 
102  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
103  if (rh)
104  delete rh;
105 
106  BESDEBUG( "fojson", "Done Cleaning module " << modname << endl );
107 }
108 
115 void FoJsonModule::dump(ostream &strm) const
116 {
117  strm << BESIndent::LMarg << "FoJsonModule::dump - (" << (void *) this << ")" << endl;
118 }
119 
123 extern "C"
124 BESAbstractModule *maker()
125 {
126  return new FoJsonModule;
127 }
128 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:77
FoJsonModule::terminate
virtual void terminate(const string &modname)
removes any registered callbacks or objects from the framework
Definition: FoJsonModule.cc:93
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
FoInstanceJsonTransmitter
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
Definition: FoInstanceJsonTransmitter.h:46
FoJsonModule::initialize
virtual void initialize(const string &modname)
initialize the module by adding call backs and registering objects with the framework
Definition: FoJsonModule.cc:65
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:50
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::dump
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
Definition: FoJsonModule.cc:115
FoDapJsonTransmitter
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
Definition: FoDapJsonTransmitter.h:46