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