bes  Updated for version 3.17.4
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 <BESContainerStorageCatalog.h>
37 #include <BESCatalogDirectory.h>
38 #include <BESCatalogList.h>
39 
40 #define DAP_CATALOG "catalog"
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  if (!BESCatalogList::TheCatalogList()->ref_catalog(DAP_CATALOG)) {
52  }
53 
54  if (!BESContainerStorageList::TheList()->ref_persistence(DAP_CATALOG)) {
56  BESContainerStorageList::TheList()->add_persistence(csc);
57  }
58 
59  BESDebug::Register(modname);
60 
61  BESDEBUG(modname, "Done Initializing Dap Reader Module " << modname << endl);
62 }
63 
64 void DapModule::terminate(const string &modname)
65 {
66  BESDEBUG(modname, "Cleaning Dap Reader Module " << modname << endl);
67 
68  BESRequestHandler *rh = 0;
69 
70  rh = BESRequestHandlerList::TheList()->remove_handler(modname);
71  if (rh) delete rh;
72 
73  BESContainerStorageList::TheList()->deref_persistence(DAP_CATALOG);
74 
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 
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.
implementation of BESContainerStorage that represents a data within a catalog repository ...
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
virtual void dump(ostream &strm) const
dump the contents of this object to the specified ostream
Definition: DapModule.cc:87
virtual bool deref_persistence(const string &persist_name)
dereference a persistent store in the list.
Represents a specific data type request handler.
static BESCatalogList * TheCatalogList()
returns the singleton BESCatalogList instance. The pthreads library insures that only one instance ca...
static void Register(const string &flagName)
register the specified debug flag
Definition: BESDebug.h:145
static void handle_dap_service(const string &handler)
static function to register a handler to handle the dap services
virtual BESRequestHandler * remove_handler(const string &handler_name)
remove and return the specified request handler