bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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
34using std::endl;
35using std::ostream;
36using 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
67void 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
95void 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
117void FoJsonModule::dump(ostream &strm) const
118{
119 strm << BESIndent::LMarg << "FoJsonModule::dump - (" << (void *) this << ")" << endl;
120}
121
125extern "C"
126BESAbstractModule *maker()
127{
128 return new FoJsonModule;
129}
130
static void Register(const std::string &flagName)
register the specified debug flag
Definition BESDebug.h:126
Represents a specific data type request handler.
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
Module that allows for OPeNDAP Data objects to be returned as geotiff files.
virtual void terminate(const std::string &modname)
removes any registered callbacks or objects from the framework
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
virtual void initialize(const std::string &modname)
initialize the module by adding call backs and registering objects with the framework
A Request Handler for the Fileout NetCDF request.