bes  Updated for version 3.20.5
BESXDModule.cc
1 // BESXDModule.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 // Authors:
27 // pwest Patrick West <pwest@ucar.edu>
28 
29 #include <iostream>
30 
31 using std::endl;
32 
33 #include <BESXDModule.h>
34 #include <BESDebug.h>
35 
36 #include <BESDapNames.h>
37 #include <BESResponseNames.h>
38 #include <BESResponseHandlerList.h>
39 #include <BESRequestHandlerList.h>
40 
41 #include <BESDapService.h>
42 
43 #include <BESTransmitter.h>
44 #include <BESReturnManager.h>
45 #include <BESTransmitterNames.h>
46 
47 #include "BESXDNames.h"
48 #include "BESXDResponseHandler.h"
49 #include "BESXDRequestHandler.h"
50 #include "BESXDTransmit.h"
51 
52 void BESXDModule::initialize(const string &modname)
53 {
54  BESDEBUG("xd", "Initializing OPeNDAP XD module " << modname << endl);
55 
56  BESRequestHandler *handler = new BESXDRequestHandler(modname);
57  BESRequestHandlerList::TheList()->add_handler(modname, handler);
58 
59  BESResponseHandlerList::TheList()->add_handler(XD_RESPONSE, BESXDResponseHandler::XDResponseBuilder);
60 
61  BESDapService::add_to_dap_service(XD_SERVICE, "OPeNDAP xml data representation");
62 
63  BESTransmitter *t = BESReturnManager::TheManager()->find_transmitter(DAP2_FORMAT);
64  if (t)
65  t->add_method(XD_TRANSMITTER, BESXDTransmit::send_basic_ascii);
66 
67  BESDebug::Register("xd");
68 
69  BESDEBUG("xd", "Done Initializing OPeNDAP XD module " << modname << endl);
70 }
71 
72 void BESXDModule::terminate(const string &modname)
73 {
74  BESDEBUG("xd", "Cleaning OPeNDAP XD module " << modname << endl);
75 
76  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
77  if (rh)
78  delete rh;
79 
80  BESResponseHandlerList::TheList()->remove_handler(XD_RESPONSE);
81 
82  BESTransmitter *t = BESReturnManager::TheManager()->find_transmitter(DAP2_FORMAT);
83  if (t)
84  t->remove_method(XD_TRANSMITTER);
85 
86  t = BESReturnManager::TheManager()->find_transmitter(DAP2_FORMAT);
87  if (t)
88  t->remove_method(XD_TRANSMITTER);
89 
90  BESDEBUG("xd", "Done Cleaning OPeNDAP XD module " << modname << endl);
91 }
92 
99 void BESXDModule::dump(ostream &strm) const
100 {
101  strm << BESIndent::LMarg << "BESXDModule::dump - (" << (void *) this << ")" << endl;
102 }
103 
104 extern "C" {
105 BESAbstractModule *maker()
106 {
107  return new BESXDModule;
108 }
109 }
110 
static void add_to_dap_service(const string &cmd, const 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:138
virtual bool add_handler(const std::string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
virtual bool add_handler(const string &handler, p_response_handler handler_method)
add a response handler to the list
Represents a specific data type request handler.
virtual bool remove_handler(const string &handler)
removes a response handler from the list
virtual void dump(ostream &strm) const
dumps information about this object
Definition: BESXDModule.cc:99
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler