bes  Updated for version 3.20.6
DmrppModule.cc
1 // DmrppModule.cc
2 
3 // Copyright (c) 2016 OPeNDAP, Inc. Author: Nathan Potter <npotter@opendap.org>
4 //
5 // modify it under the terms of the GNU Lesser General Public License
6 // as published by the Free Software Foundation; either version 2.1 of
7 // the License, or (at your option) any later version.
8 //
9 // This library is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 //
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301 U\ SA
17 //
18 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI.
19 // 02874-0112.
20 
21 #include <iostream>
22 #include <string>
23 
24 #include <BESRequestHandlerList.h>
25 #include <BESDebug.h>
26 
27 #include <BESDapService.h>
28 #include <BESResponseNames.h>
29 #include <BESContainerStorageList.h>
30 #include <BESFileContainerStorage.h>
31 #include <BESCatalogDirectory.h>
32 #include <BESCatalogList.h>
33 
34 #include "DmrppModule.h"
35 #include "DmrppRequestHandler.h"
36 
37 using namespace std;
38 
39 #define DAP_CATALOG "catalog"
40 
41 namespace dmrpp {
42 
43 void DmrppModule::initialize(const string &modname)
44 {
45  BESDebug::Register(modname);
46 
47  BESDEBUG(modname, "Initializing DMR++ Reader Module " << modname << endl);
48 
49  BESRequestHandlerList::TheList()->add_handler(modname, new DmrppRequestHandler(modname));
50 
52 
53  if (!BESCatalogList::TheCatalogList()->ref_catalog(DAP_CATALOG)) {
55  }
56 
57  if (!BESContainerStorageList::TheList()->ref_persistence(DAP_CATALOG)) {
58  BESFileContainerStorage *csc = new BESFileContainerStorage(DAP_CATALOG);
59  BESContainerStorageList::TheList()->add_persistence(csc);
60  }
61 
62  BESDEBUG(modname, "Done Initializing DMR++ Reader Module " << modname << endl);
63 }
64 
65 void DmrppModule::terminate(const string &modname)
66 {
67  BESDEBUG(modname, "Cleaning DMR++ Reader Module " << modname << endl);
68 
69  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
70  delete rh;
71 
72  BESContainerStorageList::TheList()->deref_persistence(DAP_CATALOG);
73 
74  BESCatalogList::TheCatalogList()->deref_catalog(DAP_CATALOG);
75 
76  BESDEBUG(modname, "Done Cleaning DMR++ Reader Module " << modname << endl);
77 }
78 
79 extern "C" {
80 BESAbstractModule *maker()
81 {
82  return new DmrppModule;
83 }
84 }
85 
86 void DmrppModule::dump(ostream &strm) const
87 {
88  strm << BESIndent::LMarg << "DmrppModule::dump - (" << (void *) this << ")" << endl;
89 }
90 
91 } // namespace dmrpp
92 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:74
BESRequestHandlerList::remove_handler
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Definition: BESRequestHandlerList.cc:76
BESContainerStorageList::deref_persistence
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
Definition: BESContainerStorageList.cc:163
BESCatalogDirectory
Catalogs from a directory structure.
Definition: BESCatalogDirectory.h:52
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
BESCatalogList::add_catalog
virtual bool add_catalog(BESCatalog *catalog)
adds the specified catalog to the list
Definition: BESCatalogList.cc:162
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