bes  Updated for version 3.20.6
HttpdCatalogModule.cc
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 //
4 // This file is part of bes, A C++ back-end server implementation framework
5 // for the OPeNDAP Data Access Protocol.
6 //
7 // Copyright (c) 2018 OPeNDAP, Inc.
8 // Author: Nathan Potter <ndp@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 
25 #include <iostream>
26 #include <string>
27 
28 #include <BESRequestHandlerList.h>
29 #include <BESResponseHandlerList.h>
30 #include <BESResponseNames.h>
31 
32 #include <BESContainerStorageList.h>
33 #include <BESFileContainerStorage.h>
34 #include <BESCatalogDirectory.h>
35 #include <BESCatalogList.h>
36 #include <BESDapService.h>
37 
38 #include <BESLog.h>
39 #include <BESDebug.h>
40 
41 #include "HttpdCatalogNames.h"
42 #include "HttpdCatalogModule.h"
43 #include "HttpdCatalogContainerStorage.h"
44 #include "HttpdCatalog.h"
45 
46 using namespace std;
47 
48 #define prolog string("HttpdCatalogModule::").append(__func__).append("() - ")
49 
50 namespace httpd_catalog {
51 
52 void HttpdCatalogModule::initialize(const string &modname)
53 {
54  BESDebug::Register(MODULE);
55 
56  BESDEBUG(MODULE, prolog << "Initializing Module: " << modname << endl);
57 
58  if (!BESCatalogList::TheCatalogList()->ref_catalog(HTTPD_CATALOG_NAME)) {
59  BESCatalogList::TheCatalogList()->add_catalog(new HttpdCatalog(HTTPD_CATALOG_NAME));
60  }
61 
62  if (!BESContainerStorageList::TheList()->ref_persistence(HTTPD_CATALOG_NAME)) {
63  BESContainerStorageList::TheList()->add_persistence(new HttpdCatalogContainerStorage(HTTPD_CATALOG_NAME));
64  }
65 
66  BESDEBUG(MODULE, "Done Initializing Handler: " << modname << endl);
67 }
68 
69 void HttpdCatalogModule::terminate(const string &modname)
70 {
71  BESDEBUG(MODULE, prolog << "Cleaning Module: " << modname << endl);
72 
73  BESContainerStorageList::TheList()->deref_persistence(HTTPD_CATALOG_NAME);
74 
75  BESCatalogList::TheCatalogList()->deref_catalog(HTTPD_CATALOG_NAME);
76 
77  BESDEBUG(MODULE, prolog << "Done Cleaning Module: " << modname << endl);
78 }
79 
80 extern "C" {
81 BESAbstractModule *maker()
82 {
83  return new HttpdCatalogModule;
84 }
85 }
86 
87 void HttpdCatalogModule::dump(ostream &strm) const
88 {
89  strm << BESIndent::LMarg << prolog<< "(" << (void *) this << ")" << endl;
90 }
91 
92 } // namespace httpd_catalog
BESContainerStorageList::deref_persistence
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
Definition: BESContainerStorageList.cc:163
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
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