bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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 <libdap/ServerFunctionsList.h>
30
31#include <BESRequestHandlerList.h>
32#include <TheBESKeys.h>
33#include <BESDebug.h>
34
35#include "GeoGridFunction.h"
36#include "GridFunction.h"
37#include "LinearScaleFunction.h"
38#include "VersionFunction.h"
39#include "MakeArrayFunction.h"
40#include "MakeMaskFunction.h"
41#include "BindNameFunction.h"
42#include "BindShapeFunction.h"
43#include "TabularFunction.h"
44#include "BBoxFunction.h"
45#include "RoiFunction.h"
46#include "BBoxUnionFunction.h"
47#include "MaskArrayFunction.h"
48#include "DilateArrayFunction.h"
49#include "RangeFunction.h"
50#include "BBoxCombFunction.h"
51#include "TestFunction.h"
52#include "IdentityFunction.h"
53#include "DapFunctionsRequestHandler.h"
54#include "DapFunctions.h"
55
56#if HAVE_STARE
57#include "stare/StareFunctions.h"
58#endif
59
60// Until we sort out the GDAL linking issue, do not include the gdal functions
61#define INC_GDAL 0
62
63#if INC_GDAL
64#include "ScaleGrid.h"
65#endif
66
67using std::endl;
68using std::ostream;
69using std::string;
70
71namespace functions {
72
73void DapFunctions::initialize(const string &modname)
74{
75 BESDEBUG( "dap_functions", "Initializing DAP Functions:" << endl );
76
77 // Add this module to the Request Handler List so that it can respond
78 // to version and help requests. Note the matching code to remove the
79 // handler from the list in the terminate() method.
80 BESRequestHandlerList::TheList()->add_handler(modname, new DapFunctionsRequestHandler(modname));
81
82 libdap::ServerFunctionsList::TheList()->add_function(new GridFunction());
83 libdap::ServerFunctionsList::TheList()->add_function(new GeoGridFunction());
84 libdap::ServerFunctionsList::TheList()->add_function(new LinearScaleFunction());
85
86 libdap::ServerFunctionsList::TheList()->add_function(new MakeArrayFunction());
87 libdap::ServerFunctionsList::TheList()->add_function(new MakeMaskFunction());
88 libdap::ServerFunctionsList::TheList()->add_function(new BindNameFunction());
89 libdap::ServerFunctionsList::TheList()->add_function(new BindShapeFunction());
90
91 libdap::ServerFunctionsList::TheList()->add_function(new VersionFunction());
92
93 libdap::ServerFunctionsList::TheList()->add_function(new TabularFunction());
94 libdap::ServerFunctionsList::TheList()->add_function(new BBoxFunction());
95 libdap::ServerFunctionsList::TheList()->add_function(new RoiFunction());
96 libdap::ServerFunctionsList::TheList()->add_function(new BBoxUnionFunction());
97 libdap::ServerFunctionsList::TheList()->add_function(new BBoxCombFunction());
98
99 libdap::ServerFunctionsList::TheList()->add_function(new MaskArrayFunction());
100 libdap::ServerFunctionsList::TheList()->add_function(new DilateArrayFunction());
101
102 libdap::ServerFunctionsList::TheList()->add_function(new RangeFunction());
103
104 libdap::ServerFunctionsList::TheList()->add_function(new TestFunction());
105 libdap::ServerFunctionsList::TheList()->add_function(new IdentityFunction());
106
107#if HAVE_STARE
108 libdap::ServerFunctionsList::TheList()->add_function(new StareIntersectionFunction());
109 libdap::ServerFunctionsList::TheList()->add_function(new StareCountFunction());
110 libdap::ServerFunctionsList::TheList()->add_function(new StareSubsetFunction());
111 libdap::ServerFunctionsList::TheList()->add_function(new StareSubsetArrayFunction());
112 libdap::ServerFunctionsList::TheList()->add_function(new StareBoxFunction());
113
114 // The key names and module variables used here are defined in StareFunctions.cc
115 // jhrg 5/21/20
116 stare_storage_path = TheBESKeys::TheKeys()->read_string_key(STARE_STORAGE_PATH_KEY, stare_storage_path);
117 stare_sidecar_suffix = TheBESKeys::TheKeys()->read_string_key(STARE_SIDECAR_SUFFIX_KEY, stare_sidecar_suffix);
118#endif
119
120#if INC_GDAL
121 libdap::ServerFunctionsList::TheList()->add_function(new ScaleArray());
122 libdap::ServerFunctionsList::TheList()->add_function(new ScaleGrid());
123 libdap::ServerFunctionsList::TheList()->add_function(new Scale3DArray());
124 GDALAllRegister();
125 OGRRegisterAll();
126
127 // What to do with the orig error handler? Pitch it. jhrg 10/17/16
128 (void) CPLSetErrorHandler(CPLQuietErrorHandler);
129#endif
130
131 BESDEBUG( "dap_functions", "Done initializing DAP Functions" << endl );
132}
133
134void DapFunctions::terminate(const string &modname)
135{
136 BESDEBUG( "dap_functions", "Removing DAP Functions." << endl );
137
138 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
139 delete rh;
140}
141
148void DapFunctions::dump(ostream &strm) const
149{
150 strm << BESIndent::LMarg << "DapFunctions::dump - (" << (void *) this << ")" << endl;
151}
152
153extern "C" {
154BESAbstractModule *maker()
155{
156 return new DapFunctions;
157}
158}
159
160} // namespace functions
static TheBESKeys * TheKeys()
Access to the singleton.
Definition TheBESKeys.cc:85
static std::string read_string_key(const std::string &key, const std::string &default_value)
Read a string-valued key from the bes.conf file.
virtual void dump(std::ostream &strm) const
dumps information about this object