OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESXMLCommand.cc
Go to the documentation of this file.
1 // BESXMLCommand.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 "BESXMLCommand.h"
34 #include "BESResponseHandlerList.h"
35 #include "BESSyntaxUserError.h"
36 #include "BESDataNames.h"
37 #include "BESLog.h"
38 
39 map< string, p_xmlcmd_builder> BESXMLCommand::cmd_list ;
40 
49 {
50  _dhi.make_copy( base_dhi ) ;
51 }
52 
56 void
58 {
61  if( !_dhi.response_handler )
62  {
63  string err( "Command " ) ;
64  err += _dhi.action + " does not have a registered response handler" ;
65  throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
66  }
69  << " from " << _dhi.data[REQUEST_FROM]
70  << " [" << _str_cmd << "] received" << endl ;
71 
72 }
73 
84 void
85 BESXMLCommand::add_command( const string &cmd_str, p_xmlcmd_builder cmd )
86 {
87  BESXMLCommand::cmd_list[cmd_str] = cmd ;
88 }
89 
95 bool
96 BESXMLCommand::del_command( const string &cmd_str )
97 {
98  bool ret = false ;
99 
100  BESXMLCommand::cmd_iter iter = BESXMLCommand::cmd_list.find( cmd_str ) ;
101  if( iter != BESXMLCommand::cmd_list.end() )
102  {
103  BESXMLCommand::cmd_list.erase( iter ) ;
104  }
105  return ret ;
106 }
107 
113 BESXMLCommand::find_command( const string &cmd_str )
114 {
115  return BESXMLCommand::cmd_list[cmd_str] ;
116 }
117 
124 void
125 BESXMLCommand::dump( ostream &strm ) const
126 {
127  strm << BESIndent::LMarg << "BESXMLCommand::dump - ("
128  << (void *)this << ")" << endl ;
131 }
132 
BESXMLCommand(const BESDataHandlerInterface &base_dhi)
Creates a BESXMLCommand document given a base data handler interface object.
virtual BESResponseHandler * find_handler(const string &handler)
returns the response handler with the given name from the list
#define DATA_REQUEST
Definition: BESDataNames.h:36
static bool del_command(const string &cmd_str)
Deletes the command called cmd_str from the list of possible commands.
static void add_command(const string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
#define SERVER_PID
Definition: BESDataNames.h:51
BESDataHandlerInterface _dhi
Definition: BESXMLCommand.h:57
BESXMLCommand *(* p_xmlcmd_builder)(const BESDataHandlerInterface &dhi)
Definition: BESXMLCommand.h:49
static void Indent()
Definition: BESIndent.cc:38
error thrown if there is a user syntax error in the request or any other user error ...
void make_copy(const BESDataHandlerInterface &copy_from)
deprecated
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
BESResponseHandler * response_handler
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
#define REQUEST_FROM
Definition: BESDataNames.h:38
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
static BESLog * TheLog()
Definition: BESLog.cc:347
static void UnIndent()
Definition: BESIndent.cc:44
string action
the response object requested, e.g.
virtual void dump(ostream &strm) const
dumps information about this object
static BESResponseHandlerList * TheList()
static p_xmlcmd_builder find_command(const string &cmd_str)
Find the BESXMLCommand creation function with the given name.