bes  Updated for version 3.20.6
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 
25 using std::endl;
26 using std::ostream;
27 using 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 
44 void 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 
68 void 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 
82 extern "C" {
83 BESAbstractModule *maker()
84 {
85  return new DapModule;
86 }
87 }
88 
89 void DapModule::dump(ostream &strm) const
90 {
91  strm << BESIndent::LMarg << "DapModule::dump - (" << (void *) this << ")" << endl;
92 }
93 
BESRequestHandlerList::remove_handler
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Definition: BESRequestHandlerList.cc:76
DapModule::dump
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
Definition: DapModule.cc:89
BESContainerStorageList::deref_persistence
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
Definition: BESContainerStorageList.cc:163
BESAbstractModule
Definition: BESAbstractModule.h:40
BESContainerStorageList::add_persistence
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
Definition: BESContainerStorageList.cc:81
BESCatalogList::TheCatalogList
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
Definition: BESCatalogList.cc:81
BESFileContainerStorage
implementation of BESContainerStorage that represents a data within a catalog repository
Definition: BESFileContainerStorage.h:77
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
BESDebug::Register
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
BESInternalError
exception thrown if internal error encountered
Definition: BESInternalError.h:43
BESCatalogList::default_catalog_name
virtual std::string default_catalog_name() const
The name of the default catalog.
Definition: BESCatalogList.h:116
BESDapService::handle_dap_service
static void handle_dap_service(const std::string &handler)
static function to register a handler to handle the dap services
Definition: BESDapService.cc:40
DapModule
Definition: DapModule.h:28
DapRequestHandler
Definition: DapRequestHandler.h:35