bes  Updated for version 3.20.10
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 "config.h"
29 
30 #include <iostream>
31 
32 #include "BESDebug.h"
33 #include "BESResponseHandlerList.h"
34 #include "BESReturnManager.h"
35 #include "BESRequestHandler.h"
36 #include "BESRequestHandlerList.h"
37 #include "BESXMLCommand.h"
38 
39 #include "W10NModule.h"
40 #include "W10NNames.h"
41 #include "W10nJsonTransmitter.h"
42 #include "W10nJsonRequestHandler.h"
43 #include "W10nShowPathInfoResponseHandler.h"
44 #include "W10nShowPathInfoCommand.h"
45 #include "w10n_utils.h"
46 
47 #define RETURNAS_W10N "w10n"
48 
49 
50 void
51 W10NModule::initialize( const string &modname )
52 {
53  BESDEBUG(W10N_DEBUG_KEY, "Initializing w10n Modules:" << endl ) ;
54 
55  BESRequestHandler *handler = new W10nJsonRequestHandler(modname);
56  BESRequestHandlerList::TheList()->add_handler(modname, handler);
57 
58 
59 
60  BESDEBUG( W10N_DEBUG_KEY, " adding " << W10N_SHOW_PATH_INFO_REQUEST << " command" << endl ) ;
61  BESXMLCommand::add_command( W10N_SHOW_PATH_INFO_REQUEST, W10nShowPathInfoCommand::CommandBuilder ) ;
62 
63  BESDEBUG(W10N_DEBUG_KEY, " adding " << W10N_SHOW_PATH_INFO_REQUEST_HANDLER_KEY << " response handler" << endl ) ;
64  BESResponseHandlerList::TheList()->add_handler( W10N_SHOW_PATH_INFO_REQUEST_HANDLER_KEY, W10nShowPathInfoResponseHandler::W10nShowPathInfoResponseBuilder ) ;
65 
66  BESDEBUG( W10N_DEBUG_KEY, " adding " << RETURNAS_W10N << " transmitter" << endl );
67  BESReturnManager::TheManager()->add_transmitter(RETURNAS_W10N, new W10nJsonTransmitter());
68 
69 
70  BESDebug::Register(W10N_DEBUG_KEY);
71  BESDEBUG(W10N_DEBUG_KEY, "Done Initializing w10n Modules." << endl ) ;
72 }
73 
74 void
75 W10NModule::terminate( const string & /*modname*/ )
76 {
77  BESDEBUG(W10N_DEBUG_KEY, "Removing w10n Modules:" << endl ) ;
78 
79  // BESResponseHandlerList::TheList()->remove_handler( SHOW_PATH_INFO_RESPONSE ) ;
80 
81  BESDEBUG(W10N_DEBUG_KEY, "Done Removing w10n Modules." << endl ) ;
82 }
83 
90 void
91 W10NModule::dump( ostream &strm ) const
92 {
93  strm << BESIndent::LMarg << "W10NModule::dump - ("
94  << (void *)this << ")" << std::endl ;
95 }
96 
97 extern "C"
98 {
99  BESAbstractModule *maker()
100  {
101  return new W10NModule ;
102  }
103 }
104 
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:149
virtual bool add_handler(const std::string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
Represents a specific data type request handler.
virtual bool add_handler(const std::string &handler, p_response_handler handler_method)
add a response handler to the list
static void add_command(const std::string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: W10NModule.cc:91
A Request Handler for the Fileout NetCDF request.
BESTransmitter class named "json" that transmits an OPeNDAP data object as a JSON file.