bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESUsageModule.cc
1// BESUsageModule.cc
2
3// This file is part of bes, A C++ back-end server implementation framework
4// for the OPeNDAP Data Access Protocol.
5
6// Copyright (c) 2004,2005 University Corporation for Atmospheric Research
7// Author: Patrick West <pwest@ucar.edu>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact University Corporation for Atmospheric Research at
24// 3080 Center Green Drive, Boulder, CO 80301
25
26// (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27// Please read the full copyright statement in the file COPYRIGHT_UCAR.
28//
29// Authors:
30// pwest Patrick West <pwest@ucar.edu>
31
32#include "config.h"
33
34#include <iostream>
35
36#include "BESUsageModule.h"
37
38#include "BESUsageNames.h"
39#include "BESDapNames.h"
40#include "BESResponseNames.h"
41#include "BESResponseHandlerList.h"
42
43#include "BESUsageRequestHandler.h"
44#include "BESRequestHandlerList.h"
45
46#include "BESUsageResponseHandler.h"
47
48#include "BESDapService.h"
49
50#include "BESUsageTransmit.h"
51#include "BESTransmitter.h"
52#include "BESReturnManager.h"
53#include "BESTransmitterNames.h"
54
55#include "BESDebug.h"
56
57
58using std::endl ;
59using std::ostream;
60using std::string;
61
62
63void
64BESUsageModule::initialize( const string &modname )
65{
66 BESDEBUG( "usage", "Initializing OPeNDAP Usage module "
67 << modname << endl ) ;
68
69 BESDEBUG( "usage", " adding " << modname <<
70 " request handler" << endl ) ;
71 BESRequestHandler *handler = new BESUsageRequestHandler( modname ) ;
72 BESRequestHandlerList::TheList()->add_handler( modname, handler ) ;
73
74 BESDEBUG( "usage", " adding " << Usage_RESPONSE
75 << " response handler" << endl ) ;
76 BESResponseHandlerList::TheList()->add_handler( Usage_RESPONSE, BESUsageResponseHandler::UsageResponseBuilder ) ;
77
78 BESDEBUG( "usage", "Adding to dap services" << endl ) ;
80 "OPeNDAP Data Information Page" ) ;
81
82 BESTransmitter *t = BESReturnManager::TheManager()->find_transmitter( DAP_FORMAT ) ;
83 if( t )
84 {
85 BESDEBUG( "usage", " adding basic " << Usage_TRANSMITTER
86 << " transmitter" << endl ) ;
87 t->add_method( Usage_TRANSMITTER, BESUsageTransmit::send_basic_usage ) ;
88 }
89
90 BESDEBUG( "usage", " adding usage debug context" << endl ) ;
91 BESDebug::Register( "usage" ) ;
92
93 BESDEBUG( "usage", "Done Initializing OPeNDAP Usage module"
94 << modname << endl ) ;
95}
96
97void
98BESUsageModule::terminate( const string &modname )
99{
100 BESDEBUG( "usage", "Cleaning OPeNDAP usage module " << modname << endl ) ;
101
102 BESDEBUG( "usage", " removing " << modname << " request handler "
103 << endl ) ;
104 BESRequestHandler *rh =
105 BESRequestHandlerList::TheList()->remove_handler( modname ) ;
106 if( rh ) delete rh ;
107
108 BESDEBUG( "usage", " removing " << Usage_RESPONSE
109 << " response handler " << endl ) ;
110 BESResponseHandlerList::TheList()->remove_handler( Usage_RESPONSE ) ;
111
112 BESTransmitter *t =
113 BESReturnManager::TheManager()->find_transmitter( DAP_FORMAT ) ;
114 if( t )
115 {
116 BESDEBUG( "usage", " removing basic " << Usage_TRANSMITTER
117 << " transmitter" << endl ) ;
118 t->remove_method( Usage_TRANSMITTER ) ;
119 }
120
121 t = BESReturnManager::TheManager()->find_transmitter( DAP_FORMAT ) ;
122 if( t )
123 {
124 BESDEBUG( "usage", " removing http " << Usage_TRANSMITTER
125 << " transmitter" << endl ) ;
126 t->remove_method( Usage_TRANSMITTER ) ;
127 }
128
129 BESDEBUG( "usage", "Done Cleaning OPeNDAP usage module "
130 << modname << endl ) ;
131}
132
139void
140BESUsageModule::dump( ostream &strm ) const
141{
142 strm << BESIndent::LMarg << "BESUsageModule::dump - ("
143 << (void *)this << ")" << endl ;
144}
145
146extern "C"
147{
148 BESAbstractModule *maker()
149 {
150 return new BESUsageModule ;
151 }
152}
153
static void add_to_dap_service(const std::string &cmd, const std::string &desc)
static function to add commands to the dap service
static void Register(const std::string &flagName)
register the specified debug flag
Definition BESDebug.h:126
virtual void dump(std::ostream &strm) const
dumps information about this object