bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
DapModule.cc
1// DapModule.cc
2
3// Copyright (c) 2013 OPeNDAP, Inc. Author: James Gallagher
4// <jgallagher@opendap.org>, Patrick West <pwest@opendap.org>
5// Nathan Potter <npotter@opendap.org>
6//
7// modify it under the terms of the GNU Lesser General Public License
8// as published by the Free Software Foundation; either version 2.1 of
9// the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful, but
12// WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// License along with this library; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18// 02110-1301 U\ SA
19//
20// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI.
21// 02874-0112.
22
23#include <iostream>
24
25using std::endl;
26using std::ostream;
27using std::string;
28
29#include "DapModule.h"
30#include "DapRequestHandler.h"
31
32#include <BESRequestHandlerList.h>
33#include <BESDebug.h>
34
35#include <BESDapService.h>
36#include <BESResponseNames.h>
37#include <BESContainerStorageList.h>
38#include <BESFileContainerStorage.h>
39#include <BESCatalogDirectory.h>
40#include <BESCatalogList.h>
41
42#include "BESInternalError.h"
43
44void DapModule::initialize(const string &modname)
45{
46 BESDEBUG(modname, "Initializing Dap Reader Module " << modname << endl);
47
48 BESRequestHandlerList::TheList()->add_handler(modname, new DapRequestHandler(modname));
49
51
52 string default_catalog_name = BESCatalogList::TheCatalogList()->default_catalog_name();
53 if (!BESCatalogList::TheCatalogList()->ref_catalog(default_catalog_name)) {
54 throw BESInternalError("Should never have to add the default catalog.", __FILE__, __LINE__);
55 }
56
57 // TODO this is probably bogus too. jhrg 7/23/18
58 if (!BESContainerStorageList::TheList()->ref_persistence(default_catalog_name)) {
59 BESFileContainerStorage *csc = new BESFileContainerStorage(default_catalog_name);
60 BESContainerStorageList::TheList()->add_persistence(csc);
61 }
62
63 BESDebug::Register(modname);
64
65 BESDEBUG(modname, "Done Initializing Dap Reader Module " << modname << endl);
66}
67
68void DapModule::terminate(const string &modname)
69{
70 BESDEBUG(modname, "Cleaning Dap Reader Module " << modname << endl);
71
72 delete BESRequestHandlerList::TheList()->remove_handler(modname);
73
74 string default_catalog_name = BESCatalogList::TheCatalogList()->default_catalog_name();
75 BESContainerStorageList::TheList()->deref_persistence(default_catalog_name);
76
77 BESCatalogList::TheCatalogList()->deref_catalog(default_catalog_name);
78
79 BESDEBUG(modname, "Done Cleaning Dap Reader Module " << modname << endl);
80}
81
82extern "C" {
83BESAbstractModule *maker()
84{
85 return new DapModule;
86}
87}
88
89void DapModule::dump(ostream &strm) const
90{
91 strm << BESIndent::LMarg << "DapModule::dump - (" << (void *) this << ")" << endl;
92}
93
virtual std::string default_catalog_name() const
The name of the default catalog.
static void handle_dap_service(const std::string &handler)
static function to register a handler to handle the dap services
static void Register(const std::string &flagName)
register the specified debug flag
Definition BESDebug.h:126
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
Definition DapModule.cc:89