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