bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
IdentityFunction.cc
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of libdap, A C++ implementation of the OPeNDAP Data
4// Access Protocol.
5
6// Copyright (c) 2013 OPeNDAP, Inc.
7// Authors: Nathan Potter <npotter@opendap.org>
8// James Gallagher <jgallagher@opendap.org>
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23//
24// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25
26#include "config.h"
27
28#include <sstream>
29
30#include <libdap/BaseType.h>
31#include <libdap/Float64.h>
32#include <libdap/Str.h>
33#include <libdap/Array.h>
34#include <libdap/Grid.h>
35#include <libdap/D4RValue.h>
36
37#include <libdap/Error.h>
38#include <libdap/DDS.h>
39
40#include <libdap/debug.h>
41#include <libdap/util.h>
42
43#include "BESDebug.h"
44
45#include "LinearScaleFunction.h"
46
47using namespace libdap;
48
49namespace functions {
50
51string identity_info =
52 string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
53 + "<function name=\"identity\" version=\"1.0\" href=\"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#identity\">\n"
54 + "</function>";
55
63void function_dap2_identity(int argc, BaseType * argv[], DDS &, BaseType **btpp)
64{
65 if (argc == 0) {
66 Str *response = new Str("info");
67 response->set_value(identity_info);
68 *btpp = response;
69 return;
70 }
71
72 *btpp = argv[0];
73}
74
82BaseType *function_dap4_identity(D4RValueList *args, DMR &dmr)
83{
84 BESDEBUG("function", "function_dap4_identity() BEGIN " << endl);
85
86 // DAP4 function porting information: in place of 'argc' use 'args.size()'
87 if (args == 0 || args->size() == 0) {
88 Str *response = new Str("info");
89 response->set_value(identity_info);
90 // DAP4 function porting: return a BaseType* instead of using the value-result parameter
91 return response;
92 }
93
94 return args->get_rvalue(0)->value(dmr);
95}
96} // namesspace functions