bes  Updated for version 3.20.6
W10NModule.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // W10NModule.cc
4 //
5 // This file is part of BES w10n handler
6 //
7 // Copyright (c) 2015v OPeNDAP, Inc.
8 // Author: Nathan Potter <ndp@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 // Please read the full copyright statement in the file COPYRIGHT_URI.
26 //
27 
28 #include <iostream>
29 
30 #include "BESDebug.h"
31 #include "BESResponseHandlerList.h"
32 #include "BESReturnManager.h"
33 #include "BESRequestHandler.h"
34 #include "BESRequestHandlerList.h"
35 #include "BESXMLCommand.h"
36 
37 #include "W10NModule.h"
38 #include "W10NNames.h"
39 #include "W10nJsonTransmitter.h"
40 #include "W10nJsonRequestHandler.h"
41 #include "W10nShowPathInfoResponseHandler.h"
42 #include "W10nShowPathInfoCommand.h"
43 #include "w10n_utils.h"
44 
45 #define RETURNAS_W10N "w10n"
46 
47 
48 void
49 W10NModule::initialize( const string &modname )
50 {
51  BESDEBUG(W10N_DEBUG_KEY, "Initializing w10n Modules:" << endl ) ;
52 
53  BESRequestHandler *handler = new W10nJsonRequestHandler(modname);
54  BESRequestHandlerList::TheList()->add_handler(modname, handler);
55 
56 
57 
58  BESDEBUG( W10N_DEBUG_KEY, " adding " << W10N_SHOW_PATH_INFO_REQUEST << " command" << endl ) ;
59  BESXMLCommand::add_command( W10N_SHOW_PATH_INFO_REQUEST, W10nShowPathInfoCommand::CommandBuilder ) ;
60 
61  BESDEBUG(W10N_DEBUG_KEY, " adding " << W10N_SHOW_PATH_INFO_REQUEST_HANDLER_KEY << " response handler" << endl ) ;
62  BESResponseHandlerList::TheList()->add_handler( W10N_SHOW_PATH_INFO_REQUEST_HANDLER_KEY, W10nShowPathInfoResponseHandler::W10nShowPathInfoResponseBuilder ) ;
63 
64  BESDEBUG( W10N_DEBUG_KEY, " adding " << RETURNAS_W10N << " transmitter" << endl );
65  BESReturnManager::TheManager()->add_transmitter(RETURNAS_W10N, new W10nJsonTransmitter());
66 
67 
68  BESDebug::Register(W10N_DEBUG_KEY);
69  BESDEBUG(W10N_DEBUG_KEY, "Done Initializing w10n Modules." << endl ) ;
70 }
71 
72 void
73 W10NModule::terminate( const string & /*modname*/ )
74 {
75  BESDEBUG(W10N_DEBUG_KEY, "Removing w10n Modules:" << endl ) ;
76 
77  // BESResponseHandlerList::TheList()->remove_handler( SHOW_PATH_INFO_RESPONSE ) ;
78 
79  BESDEBUG(W10N_DEBUG_KEY, "Done Removing w10n Modules." << endl ) ;
80 }
81 
88 void
89 W10NModule::dump( ostream &strm ) const
90 {
91  strm << BESIndent::LMarg << "W10NModule::dump - ("
92  << (void *)this << ")" << std::endl ;
93 }
94 
95 extern "C"
96 {
97  BESAbstractModule *maker()
98  {
99  return new W10NModule ;
100  }
101 }
102 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:74
W10nJsonTransmitter
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.
Definition: W10nJsonTransmitter.h:49
BESAbstractModule
Definition: BESAbstractModule.h:40
BESXMLCommand::add_command
static void add_command(const std::string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
Definition: BESXMLCommand.cc:86
W10NModule
Definition: W10NModule.h:34
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
W10NModule::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: W10NModule.cc:89
W10nJsonRequestHandler
A Request Handler for the Fileout NetCDF request.
Definition: W10nJsonRequestHandler.h:41
BESResponseHandlerList::add_handler
virtual bool add_handler(const std::string &handler, p_response_handler handler_method)
add a response handler to the list
Definition: BESResponseHandlerList.cc:55