bes  Updated for version 3.19.1
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 
53 #include "DapFunctionsRequestHandler.h"
54 
55 #include "DapFunctions.h"
56 #include "ScaleGrid.h"
57 
58 namespace functions {
59 
60 void DapFunctions::initialize(const string &modname)
61 {
62  BESDEBUG( "dap_functions", "Initializing DAP Functions:" << endl );
63 
64  // Add this module to the Request Handler List so that it can respond
65  // to version and help requests. Note the matching code to remove the
66  // handler from the list in the terminate() method.
67  BESRequestHandlerList::TheList()->add_handler(modname, new DapFunctionsRequestHandler(modname));
68 
69  libdap::ServerFunctionsList::TheList()->add_function(new GridFunction());
70  libdap::ServerFunctionsList::TheList()->add_function(new GeoGridFunction());
71  libdap::ServerFunctionsList::TheList()->add_function(new LinearScaleFunction());
72 
73  libdap::ServerFunctionsList::TheList()->add_function(new MakeArrayFunction());
74  libdap::ServerFunctionsList::TheList()->add_function(new MakeMaskFunction());
75  libdap::ServerFunctionsList::TheList()->add_function(new BindNameFunction());
76  libdap::ServerFunctionsList::TheList()->add_function(new BindShapeFunction());
77 
78  libdap::ServerFunctionsList::TheList()->add_function(new VersionFunction());
79 
80  libdap::ServerFunctionsList::TheList()->add_function(new TabularFunction());
81  libdap::ServerFunctionsList::TheList()->add_function(new BBoxFunction());
82  libdap::ServerFunctionsList::TheList()->add_function(new RoiFunction());
83  libdap::ServerFunctionsList::TheList()->add_function(new BBoxUnionFunction());
84 
85  libdap::ServerFunctionsList::TheList()->add_function(new MaskArrayFunction());
86  libdap::ServerFunctionsList::TheList()->add_function(new DilateArrayFunction());
87 
88  libdap::ServerFunctionsList::TheList()->add_function(new RangeFunction());
89 
90  libdap::ServerFunctionsList::TheList()->add_function(new ScaleArray());
91  libdap::ServerFunctionsList::TheList()->add_function(new ScaleGrid());
92  libdap::ServerFunctionsList::TheList()->add_function(new Scale3DArray());
93 
94  GDALAllRegister();
95  OGRRegisterAll();
96 
97  // What to do with the orig error handler? Pitch it for now. jhrg 10/17/16
98  /*CPLErrorHandler orig_err_handler =*/ (void) CPLSetErrorHandler(CPLQuietErrorHandler);
99 
100  BESDEBUG( "dap_functions", "Done initializing DAP Functions" << endl );
101 }
102 
103 void DapFunctions::terminate(const string &modname)
104 {
105  BESDEBUG( "dap_functions", "Removing DAP Functions." << endl );
106 
107  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
108  if (rh) delete rh;
109 
110 }
111 
118 void DapFunctions::dump(ostream &strm) const
119 {
120  strm << BESIndent::LMarg << "DapFunctions::dump - (" << (void *) this << ")" << endl;
121 }
122 
123 extern "C" {
124 BESAbstractModule *maker()
125 {
126  return new DapFunctions;
127 }
128 }
129 
130 }
virtual bool add_handler(const string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
Represents a specific data type request handler.
A Request Handler for the DAP Functions module.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual BESRequestHandler * remove_handler(const string &handler_name)
remove and return the specified request handler