bes  Updated for version 3.20.6
SampleModule.cc
1 // SampleModule.cc
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
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 University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #include "config.h"
34 
35 #include <iostream>
36 
37 using std::endl;
38 using std::ostream;
39 using std::string;
40 
41 #include "BESRequestHandlerList.h"
42 
43 #include "BESDebug.h"
44 #include "BESResponseHandlerList.h"
45 #include "BESResponseNames.h"
46 #include "BESXMLCommand.h"
47 
48 #include "SampleModule.h"
49 #include "SampleRequestHandler.h"
50 #include "SampleResponseNames.h"
51 #include "SampleSayResponseHandler.h"
52 #include "SampleSayXMLCommand.h"
53 
54 void SampleModule::initialize(const string &modname)
55 {
56  BESDEBUG(modname, "Initializing Sample Module " << modname << endl);
57 
58  BESRequestHandlerList::TheList()->add_handler(modname, new SampleRequestHandler(modname));
59 
60  BESResponseHandlerList::TheList()->add_handler(SAY_RESPONSE, SampleSayResponseHandler::SampleSayResponseBuilder);
61 
62  BESXMLCommand::add_command(SAY_RESPONSE, SampleSayXMLCommand::CommandBuilder);
63 
64  BESDebug::Register(modname);
65 
66  BESDEBUG(modname, "Done Initializing Sample Module " << modname << endl);
67 }
68 
69 void SampleModule::terminate(const string &modname)
70 {
71  BESDEBUG(modname, "Cleaning Sample module " << modname << endl);
72 
73  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
74  if (rh) delete rh;
75 
76  BESResponseHandlerList::TheList()->remove_handler( SAY_RESPONSE);
77 
78  BESXMLCommand::del_command( SAY_RESPONSE);
79 
80  BESDEBUG(modname, "Done Cleaning Sample module " << modname << endl);
81 }
82 
83 extern "C" {
84 BESAbstractModule *maker()
85 {
86  return new SampleModule;
87 }
88 }
89 
90 void SampleModule::dump(ostream &strm) const
91 {
92  strm << BESIndent::LMarg << "SampleModule::dump - (" << (void *) this << ")" << endl;
93 }
94 
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
SampleRequestHandler
Definition: SampleRequestHandler.h:38
BESAbstractModule
Definition: BESAbstractModule.h:40
BESXMLCommand::add_command
static void add_command(const std::string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
Definition: BESXMLCommand.cc:86
BESResponseHandlerList::remove_handler
virtual bool remove_handler(const std::string &handler)
removes a response handler from the list
Definition: BESResponseHandlerList.cc:74
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
SampleModule
Definition: SampleModule.h:38
BESXMLCommand::del_command
static void del_command(const std::string &cmd_str)
Deletes the command called cmd_str from the list of possible commands.
Definition: BESXMLCommand.cc:96
SampleModule::dump
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
Definition: SampleModule.cc:90
BESResponseHandlerList::add_handler
virtual bool add_handler(const std::string &handler, p_response_handler handler_method)
add a response handler to the list
Definition: BESResponseHandlerList.cc:55