bes Updated for version 3.20.13
NgapModule.cc
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of ngap_module, A C++ module that can be loaded in to
4// the OPeNDAP Back-End Server (BES) and is able to handle remote requests.
5
6// Copyright (c) 2020 OPeNDAP, Inc.
7// Author: Nathan Potter <ndp@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25
26#include "config.h"
27
28#include <iostream>
29#include <vector>
30#include <string>
31
32#include <BESRequestHandlerList.h>
33#include <BESDebug.h>
34#include <BESContainerStorageList.h>
35
36#include "NgapModule.h"
37#include "NgapRequestHandler.h"
38#include "NgapContainerStorage.h"
39
40using namespace std;
41using namespace ngap;
42
43void NgapModule::initialize(const string &modname)
44{
45 BESDEBUG(modname, "Initializing NGAP Module " << modname << endl);
46
47 BESDEBUG(modname, " adding " << modname << " request handler" << endl);
48 BESRequestHandlerList::TheList()->add_handler(modname, new NgapRequestHandler(modname));
49
50 BESDEBUG(modname, " adding " << modname << " container storage" << endl);
51 BESContainerStorageList::TheList()->add_persistence(new NgapContainerStorage(modname));
52
53#if 0
54 BESDEBUG(modname, " initialize the NGAP utilities and params" << endl);
55 NgapUtils::Initialize();
56#endif
57
58 BESDEBUG(modname, " adding NGAP debug context" << endl);
59 BESDebug::Register(modname);
60
61 //BESDEBUG( modname, " adding " << SHOW_NGAP_PATH_INFO_RESPONSE_STR << " command" << endl ) ;
62 //BESXMLCommand::add_command( SHOW_NGAP_PATH_INFO_RESPONSE_STR, NgapPathInfoCommand::CommandBuilder ) ;
63
64 //BESDEBUG(modname, " adding " << SHOW_NGAP_PATH_INFO_RESPONSE << " response handler" << endl ) ;
65 //BESResponseHandlerList::TheList()->add_handler( SHOW_NGAP_PATH_INFO_RESPONSE, NgapPathInfoResponseHandler::NgapPathInfoResponseBuilder ) ;
66
67 BESDEBUG(modname, "Done Initializing NGAP Module " << modname << endl);
68}
69
70void NgapModule::terminate(const string &modname)
71{
72 BESDEBUG(modname, "Cleaning NGAP module " << modname << endl);
73/*
74 BESResponseHandlerList::TheList()->remove_handler( SHOW_NGAP_PATH_INFO_RESPONSE) ;
75 BESXMLCommand::del_command( SHOW_NGAP_PATH_INFO_RESPONSE_STR) ;
76
77 BESDEBUG(modname, " removing " << modname << " request handler" << endl);
78 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
79 if (rh)
80 delete rh;
81
82 BESContainerStorageList::TheList()->deref_persistence(modname);
83*/
84
85 // TERM_END
86 BESDEBUG(modname, "Done Cleaning NGAP module " << modname << endl);
87}
88
89void NgapModule::dump(ostream &strm) const
90{
91 strm << BESIndent::LMarg << "NgapModule::dump - (" << (void *) this << ")" << endl;
92}
93
94extern "C"
95BESAbstractModule *maker()
96{
97 return new NgapModule;
98}
99
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:149
virtual bool add_handler(const std::string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
implementation of BESContainerStorageVolatile that represents a list of remote requests
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
Definition: NgapModule.cc:89