bes  Updated for version 3.20.10
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 #define prolog string("DmrppModule::").append(__func__).append("() - ")
42 
43 namespace dmrpp {
44 
45 void DmrppModule::initialize(const string &modname)
46 {
47  BESDebug::Register(modname);
48 
49  BESDEBUG(modname, prolog << "Initializing DMR++ Reader Module " << modname << endl);
50 
51  BESRequestHandlerList::TheList()->add_handler(modname, new DmrppRequestHandler(modname));
52 
54 
55  if (!BESCatalogList::TheCatalogList()->ref_catalog(DAP_CATALOG)) {
57  }
58 
59  if (!BESContainerStorageList::TheList()->ref_persistence(DAP_CATALOG)) {
60  BESFileContainerStorage *csc = new BESFileContainerStorage(DAP_CATALOG);
61  BESContainerStorageList::TheList()->add_persistence(csc);
62  }
63 
64  BESDEBUG(modname, prolog << "Done Initializing DMR++ Reader Module " << modname << endl);
65 }
66 
67 void DmrppModule::terminate(const string &modname)
68 {
69  BESDEBUG(modname, prolog << "Cleaning DMR++ Reader Module " << modname << endl);
70 
71  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
72  delete rh;
73 
74  BESContainerStorageList::TheList()->deref_persistence(DAP_CATALOG);
75 
76  BESCatalogList::TheCatalogList()->deref_catalog(DAP_CATALOG);
77 
78  BESDEBUG(modname, prolog << "Done Cleaning DMR++ Reader Module " << modname << endl);
79 }
80 
81 extern "C" {
82 BESAbstractModule *maker()
83 {
84  return new DmrppModule;
85 }
86 }
87 
88 void DmrppModule::dump(ostream &strm) const
89 {
90  strm << BESIndent::LMarg << "DmrppModule::dump - (" << (void *) this << ")" << endl;
91 }
92 
93 } // namespace dmrpp
94 
Catalogs from a directory structure.
virtual bool add_catalog(BESCatalog *catalog)
adds the specified catalog to the list
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
static void handle_dap_service(const std::string &handler)
static function to register a handler to handle the dap services
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:149
implementation of BESContainerStorage that represents a data within a catalog repository
virtual bool add_handler(const std::string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Represents a specific data type request handler.