bes  Updated for version 3.20.5
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 
27 #include "DapModule.h"
28 #include "DapRequestHandler.h"
29 
30 #include <BESRequestHandlerList.h>
31 #include <BESDebug.h>
32 
33 #include <BESDapService.h>
34 #include <BESResponseNames.h>
35 #include <BESContainerStorageList.h>
36 #include <BESFileContainerStorage.h>
37 #include <BESCatalogDirectory.h>
38 #include <BESCatalogList.h>
39 
40 #include "BESInternalError.h"
41 
42 void DapModule::initialize(const string &modname)
43 {
44  BESDEBUG(modname, "Initializing Dap Reader Module " << modname << endl);
45 
46  BESRequestHandlerList::TheList()->add_handler(modname, new DapRequestHandler(modname));
47 
49 
50  string default_catalog_name = BESCatalogList::TheCatalogList()->default_catalog_name();
51  if (!BESCatalogList::TheCatalogList()->ref_catalog(default_catalog_name)) {
52  throw BESInternalError("Should never have to add the default catalog.", __FILE__, __LINE__);
53  }
54 
55  // TODO this is probably bogus too. jhrg 7/23/18
56  if (!BESContainerStorageList::TheList()->ref_persistence(default_catalog_name)) {
57  BESFileContainerStorage *csc = new BESFileContainerStorage(default_catalog_name);
58  BESContainerStorageList::TheList()->add_persistence(csc);
59  }
60 
61  BESDebug::Register(modname);
62 
63  BESDEBUG(modname, "Done Initializing Dap Reader Module " << modname << endl);
64 }
65 
66 void DapModule::terminate(const string &modname)
67 {
68  BESDEBUG(modname, "Cleaning Dap Reader Module " << modname << endl);
69 
70  delete BESRequestHandlerList::TheList()->remove_handler(modname);
71 
72  string default_catalog_name = BESCatalogList::TheCatalogList()->default_catalog_name();
73  BESContainerStorageList::TheList()->deref_persistence(default_catalog_name);
74 
75  BESCatalogList::TheCatalogList()->deref_catalog(default_catalog_name);
76 
77  BESDEBUG(modname, "Done Cleaning Dap Reader Module " << modname << endl);
78 }
79 
80 extern "C" {
81 BESAbstractModule *maker()
82 {
83  return new DapModule;
84 }
85 }
86 
87 void DapModule::dump(ostream &strm) const
88 {
89  strm << BESIndent::LMarg << "DapModule::dump - (" << (void *) this << ")" << endl;
90 }
91 
BESRequestHandlerList::remove_handler
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Definition: BESRequestHandlerList.cc:72
BESContainerStorageList::deref_persistence
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
Definition: BESContainerStorageList.cc:161
BESAbstractModule
Definition: BESAbstractModule.h:42
DapModule::dump
virtual void dump(ostream &strm) const
dump the contents of this object to the specified ostream
Definition: DapModule.cc:87
BESContainerStorageList::add_persistence
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
Definition: BESContainerStorageList.cc:79
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:82
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:50
BESDebug::Register
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
BESInternalError
exception thrown if inernal error encountered
Definition: BESInternalError.h:43
BESDapService::handle_dap_service
static void handle_dap_service(const string &handler)
static function to register a handler to handle the dap services
Definition: BESDapService.cc:38
BESCatalogList::default_catalog_name
virtual std::string default_catalog_name() const
The name of the default catalog.
Definition: BESCatalogList.h:116
DapModule
Definition: DapModule.h:28
DapRequestHandler
Definition: DapRequestHandler.h:35