bes  Updated for version 3.20.6
BESUsageResponseHandler.cc
1 // BESUsageResponseHandler.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,2005 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 "../usage/BESUsageResponseHandler.h"
34 
35 #include <DDS.h>
36 #include "../usage/BESUsage.h"
37 #include "../usage/BESUsageNames.h"
38 #include "../usage/BESUsageTransmit.h"
39 #include "BESRequestHandlerList.h"
40 #include "BESDapNames.h"
41 #include "BESDASResponse.h"
42 #include "BESDDSResponse.h"
43 #include "BESTransmitter.h"
44 
45 using namespace libdap;
46 
47 BESUsageResponseHandler::BESUsageResponseHandler( const string &name )
48  : BESResponseHandler( name )
49 {
50 }
51 
52 BESUsageResponseHandler::~BESUsageResponseHandler( )
53 {
54 }
55 
72 void
74 {
75  dhi.action_name = Usage_RESPONSE_STR ;
76 
77  // Create the DDS.
78  // NOTE: It is the responsbility of the specific request handler to set
79  // the BaseTypeFactory. It is set to NULL here
80  DDS *dds = new DDS( NULL, "virtual" ) ;
81  BESDDSResponse *bdds = new BESDDSResponse( dds ) ;
82  d_response_object = bdds ;
83  d_response_name = DDS_RESPONSE ;
84  dhi.action = DDS_RESPONSE ;
85  BESRequestHandlerList::TheList()->execute_each( dhi ) ;
86 
87  // Fill the DAS
88  DAS *das = new DAS ;
89  BESDASResponse *bdas = new BESDASResponse( das ) ;
90  d_response_object = bdas ;
91  d_response_name = DAS_RESPONSE ;
92  dhi.action = DAS_RESPONSE ;
93  BESRequestHandlerList::TheList()->execute_each( dhi ) ;
94 
95  BESUsage *usage = new BESUsage( bdas, bdds ) ;
96  d_response_object = usage ;
97  dhi.action = Usage_RESPONSE ;
98 }
99 
112 void
115 {
116  if( d_response_object )
117  {
118  transmitter->send_response( Usage_TRANSMITTER, d_response_object, dhi ) ;
119  }
120 }
121 
123 BESUsageResponseHandler::UsageResponseBuilder( const string &handler_name )
124 {
125  return new BESUsageResponseHandler( handler_name ) ;
126 }
127 
BESDataHandlerInterface::action
std::string action
the response object requested, e.g. das, dds
Definition: BESDataHandlerInterface.h:79
BESUsage
container for a DAS and DDS needed to write out the usage information for a dataset.
Definition: BESUsage.h:51
BESUsageResponseHandler::execute
virtual void execute(BESDataHandlerInterface &dhi)
executes the command 'get Usage for <def_name>;' by executing the request for each container in the s...
Definition: BESUsageResponseHandler.cc:73
BESDASResponse
Represents an OPeNDAP DAS DAP2 data object within the BES.
Definition: BESDASResponse.h:44
BESUsageResponseHandler::transmit
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object
Definition: BESUsageResponseHandler.cc:113
BESRequestHandlerList::execute_each
virtual void execute_each(BESDataHandlerInterface &dhi)
for each container in the given data handler interface, execute the given request
Definition: BESRequestHandlerList.cc:167
libdap
Definition: BESDapFunctionResponseCache.h:35
BESResponseHandler
handler object that knows how to create a specific response object
Definition: BESResponseHandler.h:77
BESTransmitter
Definition: BESTransmitter.h:47
BESDDSResponse
Holds a DDS object within the BES.
Definition: BESDDSResponse.h:50
BESUsageResponseHandler
response handler that builds an OPeNDAP Usage response object
Definition: BESUsageResponseHandler.h:49
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56