bes  Updated for version 3.20.10
BESAsciiModule.cc
1 // BESAsciiModule.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 "BESAsciiModule.h"
37 #include "BESDebug.h"
38 
39 //#include "BESAsciiNames.h"
40 #include "BESDapNames.h"
41 #include "BESResponseNames.h"
42 #include "BESResponseHandlerList.h"
43 #include "BESTransmitter.h"
44 #include "BESReturnManager.h"
45 #include "BESTransmitterNames.h"
46 
47 //#include "BESAsciiResponseHandler.h"
48 
49 #include "BESAsciiRequestHandler.h"
50 #include "BESRequestHandlerList.h"
51 
52 #include "BESDapService.h"
53 
54 #include "BESAsciiTransmit.h"
55 
56 #if 0
57 #define ASCII_RESPONSE "get.ascii"
58 #define ASCII_SERVICE "ascii"
59 #define ASCII_RESPONSE_STR "getAscii"
60 #endif
61 
62 using std::endl;
63 using std::ostream;
64 using std::string;
65 
66 
67 void BESAsciiModule::initialize(const string &modname)
68 {
69  BESDEBUG("ascii", "Initializing module " << modname << endl);
70 
71  BESRequestHandler *handler = new BESAsciiRequestHandler(modname);
72  BESRequestHandlerList::TheList()->add_handler(modname, handler);
73 
74  BESReturnManager::TheManager()->add_transmitter(ASCII_TRANSMITTER, new BESAsciiTransmit());
75  BESReturnManager::TheManager()->add_transmitter(DAP4_CSV_TRANSMITTER, new BESAsciiTransmit());
76 
77  BESDebug::Register("ascii");
78 
79  BESDEBUG("ascii", "Done Initializing module " << modname << endl);
80 }
81 
82 void BESAsciiModule::terminate(const string &modname)
83 {
84  BESDEBUG("ascii", "Cleaning module " << modname << endl);
85 
86  BESReturnManager::TheManager()->del_transmitter(ASCII_TRANSMITTER);
87  BESReturnManager::TheManager()->del_transmitter(DAP4_CSV_TRANSMITTER);
88 
89  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
90  if (rh)
91  delete rh;
92 
93  BESDEBUG("ascii", "Done Cleaning module " << modname << endl);
94 }
95 
102 void BESAsciiModule::dump(ostream &strm) const
103 {
104  strm << BESIndent::LMarg << "BESAsciiModule::dump - (" << (void *) this << ")" << endl;
105 }
106 
107 extern "C" {
108 BESAbstractModule *maker()
109 {
110  return new BESAsciiModule;
111 }
112 }
113 
virtual void dump(std::ostream &strm) const
dumps information about this object
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
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Represents a specific data type request handler.