bes  Updated for version 3.20.5
DapFunctions.cc
1 // DapFunctions.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) 2013 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
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 OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #include "config.h"
26 
27 #include <iostream>
28 
29 #include <gdal.h> // needed for scale_{grid,array}
30 
31 #include <ServerFunctionsList.h>
32 
33 #include <BESRequestHandlerList.h>
34 
35 #include <BESDebug.h>
36 
37 #include "GeoGridFunction.h"
38 #include "GridFunction.h"
39 #include "LinearScaleFunction.h"
40 #include "VersionFunction.h"
41 #include "MakeArrayFunction.h"
42 #include "MakeMaskFunction.h"
43 #include "BindNameFunction.h"
44 #include "BindShapeFunction.h"
45 #include "TabularFunction.h"
46 #include "BBoxFunction.h"
47 #include "RoiFunction.h"
48 #include "BBoxUnionFunction.h"
49 #include "MaskArrayFunction.h"
50 #include "DilateArrayFunction.h"
51 #include "RangeFunction.h"
52 #include "BBoxCombFunction.h"
53 
54 #include "DapFunctionsRequestHandler.h"
55 
56 #include "DapFunctions.h"
57 #include "ScaleGrid.h"
58 
59 namespace functions {
60 
61 void DapFunctions::initialize(const string &modname)
62 {
63  BESDEBUG( "dap_functions", "Initializing DAP Functions:" << endl );
64 
65  // Add this module to the Request Handler List so that it can respond
66  // to version and help requests. Note the matching code to remove the
67  // handler from the list in the terminate() method.
68  BESRequestHandlerList::TheList()->add_handler(modname, new DapFunctionsRequestHandler(modname));
69 
70  libdap::ServerFunctionsList::TheList()->add_function(new GridFunction());
71  libdap::ServerFunctionsList::TheList()->add_function(new GeoGridFunction());
72  libdap::ServerFunctionsList::TheList()->add_function(new LinearScaleFunction());
73 
74  libdap::ServerFunctionsList::TheList()->add_function(new MakeArrayFunction());
75  libdap::ServerFunctionsList::TheList()->add_function(new MakeMaskFunction());
76  libdap::ServerFunctionsList::TheList()->add_function(new BindNameFunction());
77  libdap::ServerFunctionsList::TheList()->add_function(new BindShapeFunction());
78 
79  libdap::ServerFunctionsList::TheList()->add_function(new VersionFunction());
80 
81  libdap::ServerFunctionsList::TheList()->add_function(new TabularFunction());
82  libdap::ServerFunctionsList::TheList()->add_function(new BBoxFunction());
83  libdap::ServerFunctionsList::TheList()->add_function(new RoiFunction());
84  libdap::ServerFunctionsList::TheList()->add_function(new BBoxUnionFunction());
85  libdap::ServerFunctionsList::TheList()->add_function(new BBoxCombFunction());
86 
87  libdap::ServerFunctionsList::TheList()->add_function(new MaskArrayFunction());
88  libdap::ServerFunctionsList::TheList()->add_function(new DilateArrayFunction());
89 
90  libdap::ServerFunctionsList::TheList()->add_function(new RangeFunction());
91 
92  libdap::ServerFunctionsList::TheList()->add_function(new ScaleArray());
93  libdap::ServerFunctionsList::TheList()->add_function(new ScaleGrid());
94  libdap::ServerFunctionsList::TheList()->add_function(new Scale3DArray());
95 
96  GDALAllRegister();
97  OGRRegisterAll();
98 
99  // What to do with the orig error handler? Pitch it for now. jhrg 10/17/16
100  /*CPLErrorHandler orig_err_handler =*/ (void) CPLSetErrorHandler(CPLQuietErrorHandler);
101 
102  BESDEBUG( "dap_functions", "Done initializing DAP Functions" << endl );
103 }
104 
105 void DapFunctions::terminate(const string &modname)
106 {
107  BESDEBUG( "dap_functions", "Removing DAP Functions." << endl );
108 
109  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
110  if (rh) delete rh;
111 
112 }
113 
120 void DapFunctions::dump(ostream &strm) const
121 {
122  strm << BESIndent::LMarg << "DapFunctions::dump - (" << (void *) this << ")" << endl;
123 }
124 
125 extern "C" {
126 BESAbstractModule *maker()
127 {
128  return new DapFunctions;
129 }
130 }
131 
132 }
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
BESAbstractModule
Definition: BESAbstractModule.h:42
DapFunctionsRequestHandler
A Request Handler for the DAP Functions module.
Definition: DapFunctionsRequestHandler.h:39
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
functions::DapFunctions::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: DapFunctions.cc:120
functions::DapFunctions
Definition: DapFunctions.h:32