bes  Updated for version 3.20.5
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 <iostream>
33 
34 using std::endl ;
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 
58 void
59 BESUsageModule::initialize( const string &modname )
60 {
61  BESDEBUG( "usage", "Initializing OPeNDAP Usage module "
62  << modname << endl ) ;
63 
64  BESDEBUG( "usage", " adding " << modname <<
65  " request handler" << endl ) ;
66  BESRequestHandler *handler = new BESUsageRequestHandler( modname ) ;
67  BESRequestHandlerList::TheList()->add_handler( modname, handler ) ;
68 
69  BESDEBUG( "usage", " adding " << Usage_RESPONSE
70  << " response handler" << endl ) ;
71  BESResponseHandlerList::TheList()->add_handler( Usage_RESPONSE, BESUsageResponseHandler::UsageResponseBuilder ) ;
72 
73  BESDEBUG( "usage", "Adding to dap services" << endl ) ;
74  BESDapService::add_to_dap_service( Usage_SERVICE,
75  "OPeNDAP Data Information Page" ) ;
76 
77  BESTransmitter *t = BESReturnManager::TheManager()->find_transmitter( DAP2_FORMAT ) ;
78  if( t )
79  {
80  BESDEBUG( "usage", " adding basic " << Usage_TRANSMITTER
81  << " transmitter" << endl ) ;
82  t->add_method( Usage_TRANSMITTER, BESUsageTransmit::send_basic_usage ) ;
83  }
84 
85  BESDEBUG( "usage", " adding usage debug context" << endl ) ;
86  BESDebug::Register( "usage" ) ;
87 
88  BESDEBUG( "usage", "Done Initializing OPeNDAP Usage module"
89  << modname << endl ) ;
90 }
91 
92 void
93 BESUsageModule::terminate( const string &modname )
94 {
95  BESDEBUG( "usage", "Cleaning OPeNDAP usage module " << modname << endl ) ;
96 
97  BESDEBUG( "usage", " removing " << modname << " request handler "
98  << endl ) ;
99  BESRequestHandler *rh =
100  BESRequestHandlerList::TheList()->remove_handler( modname ) ;
101  if( rh ) delete rh ;
102 
103  BESDEBUG( "usage", " removing " << Usage_RESPONSE
104  << " response handler " << endl ) ;
105  BESResponseHandlerList::TheList()->remove_handler( Usage_RESPONSE ) ;
106 
107  BESTransmitter *t =
108  BESReturnManager::TheManager()->find_transmitter( DAP2_FORMAT ) ;
109  if( t )
110  {
111  BESDEBUG( "usage", " removing basic " << Usage_TRANSMITTER
112  << " transmitter" << endl ) ;
113  t->remove_method( Usage_TRANSMITTER ) ;
114  }
115 
116  t = BESReturnManager::TheManager()->find_transmitter( DAP2_FORMAT ) ;
117  if( t )
118  {
119  BESDEBUG( "usage", " removing http " << Usage_TRANSMITTER
120  << " transmitter" << endl ) ;
121  t->remove_method( Usage_TRANSMITTER ) ;
122  }
123 
124  BESDEBUG( "usage", "Done Cleaning OPeNDAP usage module "
125  << modname << endl ) ;
126 }
127 
134 void
135 BESUsageModule::dump( ostream &strm ) const
136 {
137  strm << BESIndent::LMarg << "BESUsageModule::dump - ("
138  << (void *)this << ")" << endl ;
139 }
140 
141 extern "C"
142 {
143  BESAbstractModule *maker()
144  {
145  return new BESUsageModule ;
146  }
147 }
148 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:77
BESRequestHandlerList::remove_handler
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Definition: BESRequestHandlerList.cc:72
BESDapService::add_to_dap_service
static void add_to_dap_service(const string &cmd, const string &desc)
static function to add commands to the dap service
Definition: BESDapService.cc:45
BESAbstractModule
Definition: BESAbstractModule.h:42
BESUsageModule
Definition: BESUsageModule.h:37
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
BESResponseHandlerList::remove_handler
virtual bool remove_handler(const string &handler)
removes a response handler from the list
Definition: BESResponseHandlerList.cc:70
BESTransmitter
Definition: BESTransmitter.h:47
BESUsageRequestHandler
Definition: BESUsageRequestHandler.h:39
BESUsageModule::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition: BESUsageModule.cc:135
BESResponseHandlerList::add_handler
virtual bool add_handler(const string &handler, p_response_handler handler_method)
add a response handler to the list
Definition: BESResponseHandlerList.cc:51