bes  Updated for version 3.20.13
FONcModule.cc
1 // FONcModule.cc
2 
3 // This file is part of BES filout NetCDF Module.
4 
5 // Copyright (c) 2004,2005 University Corporation for Atmospheric Research
6 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You can contact University Corporation for Atmospheric Research at
23 // 3080 Center Green Drive, Boulder, CO 80301
24 
25 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
26 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
27 //
28 // Authors:
29 // pwest Patrick West <pwest@ucar.edu>
30 // jgarcia Jose Garcia <jgarcia@ucar.edu>
31 
32 #include "config.h"
33 
34 #include <iostream>
35 
36 using std::endl;
37 
38 #include "FONcNames.h"
39 #include "FONcBaseType.h"
40 #include "FONcModule.h"
41 #include "FONcTransmitter.h"
42 #include "FONcRequestHandler.h"
43 #include "BESRequestHandlerList.h"
44 
45 #include <BESReturnManager.h>
46 
47 #include <BESServiceRegistry.h>
48 #include <BESDapNames.h>
49 
50 #include <TheBESKeys.h>
51 #include <BESDebug.h>
52 
63 void FONcModule::initialize(const string &modname)
64 {
65  BESDEBUG("fonc", "Initializing module " << modname << endl);
66 
67  BESRequestHandler *handler = new FONcRequestHandler(modname);
68  BESRequestHandlerList::TheList()->add_handler(modname, handler);
69 
70  BESReturnManager::TheManager()->add_transmitter(FONC_RETURN_AS_NETCDF3, new FONcTransmitter());
71 
72  BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, FONC_RETURN_AS_NETCDF3);
73 
74  BESReturnManager::TheManager()->add_transmitter(FONC_RETURN_AS_NETCDF4, new FONcTransmitter());
75 
76  BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DATA_SERVICE, FONC_RETURN_AS_NETCDF4);
77 
78  //BESReturnManager::TheManager()->add_transmitter( RETURNAS_NETCDF4, new FONcTransmitter());
79 
80  BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DAP4DATA_SERVICE, FONC_RETURN_AS_NETCDF4);
81 
82 
83  BESDebug::Register("fonc");
84 
85  BESDEBUG("fonc", "Done Initializing module " << modname << endl);
86 }
87 
96 void FONcModule::terminate(const string &modname)
97 {
98  BESDEBUG("fonc", "Cleaning module " << modname << endl);
99 
100  BESReturnManager::TheManager()->del_transmitter(FONC_RETURN_AS_NETCDF3);
101 
102  BESReturnManager::TheManager()->del_transmitter(FONC_RETURN_AS_NETCDF4);
103 
104  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
105  delete rh;
106 
107  BESDEBUG("fonc", "Done Cleaning module " << modname << endl);
108 }
109 
116 void FONcModule::dump(ostream &strm) const
117 {
118  strm << BESIndent::LMarg << "FONcModule::dump - (" << (void *) this << ")" << endl;
119 }
120 
124 extern "C"
125 BESAbstractModule *maker()
126 {
127  return new FONcModule;
128 }
129 
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.
virtual void add_format(const std::string &service, const std::string &cmd, const std::string &format)
add a format response to a command of a service
Module that allows for OPeNDAP Data objects to be returned as netcdf files.
Definition: FONcModule.h:52
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
Definition: FONcModule.cc:116
virtual void initialize(const std::string &modname)
initialize the module by adding callbacks and registering objects with the framework
Definition: FONcModule.cc:63
virtual void terminate(const std::string &modname)
removes any registered callbacks or objects from the framework
Definition: FONcModule.cc:96
A Request Handler for the Fileout NetCDF request.
BESTransmitter class named "netcdf" that transmits an OPeNDAP data object as a netcdf file.