bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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 <BESReturnManager.h>
35#include <BESServiceRegistry.h>
36#include <BESDapNames.h>
37
38#include "DmrppModule.h"
39#include "DmrppRequestHandler.h"
40
41#include "writer/FODmrppTransmitter.h"
42
43#define RETURNAS_DMRPP "dmrpp"
44
45using namespace std;
46
47#define DAP_CATALOG "catalog"
48
49#define prolog string("DmrppModule::").append(__func__).append("() - ")
50
51namespace dmrpp {
52
53void DmrppModule::initialize(const string &modname)
54{
55 BESDebug::Register(modname);
56
57 BESDEBUG(modname, prolog << "Initializing DMR++ Reader Module " << modname << endl);
58
59 BESRequestHandlerList::TheList()->add_handler(modname, new DmrppRequestHandler(modname));
60
62
63 if (!BESCatalogList::TheCatalogList()->ref_catalog(DAP_CATALOG)) {
64 BESCatalogList::TheCatalogList()->add_catalog(new BESCatalogDirectory(DAP_CATALOG));
65 }
66
67 if (!BESContainerStorageList::TheList()->ref_persistence(DAP_CATALOG)) {
68 BESFileContainerStorage *csc = new BESFileContainerStorage(DAP_CATALOG);
69 BESContainerStorageList::TheList()->add_persistence(csc);
70 }
71
72 /*BESDEBUG(modname, " adding " << modname << " dmrpp-ngap container storage" << endl);
73 BESContainerStorageList::TheList()->add_persistence(new NgapBuildDmrppContainerStorage(modname));*/
74
75 // This part of the handler sets up transmitters that return DMRPP responses
76 BESReturnManager::TheManager()->add_transmitter(RETURNAS_DMRPP, new FODmrppTransmitter());
77 BESServiceRegistry::TheRegistry()->add_format(OPENDAP_SERVICE, DAP4DATA_SERVICE, RETURNAS_DMRPP);
78
79 BESDEBUG(modname, prolog << "Done Initializing DMR++ Reader Module " << modname << endl);
80}
81
82void DmrppModule::terminate(const string &modname)
83{
84 BESDEBUG(modname, prolog << "Cleaning DMR++ Reader Module " << modname << endl);
85
86 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
87 delete rh;
88
89 BESContainerStorageList::TheList()->deref_persistence(DAP_CATALOG);
90
91 BESCatalogList::TheCatalogList()->deref_catalog(DAP_CATALOG);
92
93 BESDEBUG(modname, prolog << "Done Cleaning DMR++ Reader Module " << modname << endl);
94}
95
96extern "C" {
97BESAbstractModule *maker()
98{
99 return new DmrppModule;
100}
101}
102
103void DmrppModule::dump(ostream &strm) const
104{
105 strm << BESIndent::LMarg << "DmrppModule::dump - (" << (void *) this << ")" << endl;
106}
107
108} // namespace dmrpp
109
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:126
virtual void add_format(const std::string &service, const std::string &cmd, const std::string &format)
add a format response to a command of a service
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream