OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
DapModule.cc
Go to the documentation of this file.
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 #include <iostream>
23 
24 using std::endl;
25 
26 #include "DapModule.h"
27 #include "DapRequestHandler.h"
28 #include "DapResponseNames.h"
29 
30 #include <BESRequestHandlerList.h>
31 #include <BESDebug.h>
32 //#include <BESResponseHandlerList.h>
33 #include <BESResponseNames.h>
36 #include <BESCatalogDirectory.h>
37 #include <BESCatalogList.h>
38 
39 #define DAP_CATALOG "catalog"
40 
41 void DapModule::initialize(const string &modname)
42 {
43  BESDEBUG(modname, "Initializing Dap Module " << modname << endl);
44 
45  BESDEBUG(modname, " adding dap request handler" << endl);
47 
48  BESDEBUG(modname, " adding " << DAP_CATALOG << " catalog" << endl);
49  if (!BESCatalogList::TheCatalogList()->ref_catalog(DAP_CATALOG)) {
51  }
52  else {
53  BESDEBUG(modname, " catalog already exists, skipping" << endl);
54  }
55 
56  BESDEBUG(modname, " adding catalog container storage " << DAP_CATALOG << endl);
57  if (!BESContainerStorageList::TheList()->ref_persistence(DAP_CATALOG)) {
60  }
61  else {
62  BESDEBUG(modname, " storage already exists, skipping" << endl);
63  }
64 
65  BESDEBUG(modname, " adding Dap debug context" << endl);
66  BESDebug::Register(modname);
67 
68  BESDEBUG(modname, "Done Initializing Dap Module " << modname << endl);
69 }
70 
71 void DapModule::terminate(const string &modname)
72 {
73  BESDEBUG(modname, "Cleaning Dap module " << modname << endl);
74 
75  BESRequestHandler *rh = 0;
76 
77  BESDEBUG(modname, " removing dap request handler" << endl);
79  if (rh) delete rh;
80  rh = 0;
81 
82  BESDEBUG("nc", " removing catalog container storage" << DAP_CATALOG << endl);
84 
85  BESDEBUG("nc", " removing " << DAP_CATALOG << " catalog" << endl);
87 
88  BESDEBUG(modname, "Done Cleaning Dap module " << modname << endl);
89 }
90 
91 extern "C" {
93 {
94  return new DapModule;
95 }
96 }
97 
98 void DapModule::dump(ostream &strm) const
99 {
100  strm << BESIndent::LMarg << "DapModule::dump - (" << (void *) this << ")" << endl;
101 }
102 
virtual bool add_handler(const string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
virtual bool add_catalog(BESCatalog *catalog)
adds the speciifed catalog to the list
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
virtual void dump(ostream &strm) const
dump the contents of this object to the specified ostream
Definition: DapModule.cc:98
implementation of BESContainerStorage that represents a data within a catalog repository ...
virtual void terminate(const string &modname)
Definition: DapModule.cc:71
virtual bool deref_catalog(const string &catalog_name)
de-reference the specified catalog and remove from list if no longer referenced
builds catalogs from a directory structure
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
virtual bool deref_persistence(const string &persist_name)
dereference a persistent store in the list.
Represents a specific data type request handler.
static BESRequestHandlerList * TheList()
static BESContainerStorageList * TheList()
BESAbstractModule * maker()
Definition: DapModule.cc:92
#define DAP_CATALOG
Definition: DapModule.cc:39
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
virtual void initialize(const string &modname)
Definition: DapModule.cc:41
static BESCatalogList * TheCatalogList()
returns the singleton BESCatalogList instance.
static void Register(const string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
virtual BESRequestHandler * remove_handler(const string &handler_name)
remove and return the specified request handler