OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
TabularFunction.h
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of the BES, A C++ implementation of the OPeNDAP
4 // Hyrax data server
5 
6 // Copyright (c) 2015 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@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 #include <ServerFunction.h>
26 
27 namespace libdap {
28 
29 class BaseType;
30 class Array;
31 class DDS;
32 
33 class TabularFunction: public libdap::ServerFunction
34 {
35 private:
36  friend class TabularFunctionTest;
38 
39  typedef std::vector< std::vector<BaseType*> *> SequenceValues;
40  typedef std::vector<unsigned long> Shape;
41 
42  static void function_dap2_tabular(int argc, BaseType *argv[], DDS &dds, BaseType **btpp);
43  // static BaseType *function_dap4_tabular(D4RValueList *args, DMR &dmr);
44 
45  // This
46  static void function_dap2_tabular_2(int argc, BaseType *argv[], DDS &, BaseType **btpp);
47 
48  // These are static so that the code does not have to make a TabularFunction
49  // instance to access them. They are 'in' TabularFunction to control the name
50  // space - they were static functions but that made it impossible to write
51  // unit tests.
52  static Shape array_shape(Array *a);
53  static bool shape_matches(Array *a, const Shape &shape);
54  static bool dep_indep_match(const Shape &dep_shape, const Shape &indep_shape);
55 
56  static unsigned long number_of_values(const Shape &shape);
57 
58  static void build_columns(unsigned long n, BaseType *btp, std::vector<Array*> &arrays, Shape &shape);
59 
60  static void read_values(const std::vector<Array*> &arrays);
61 
62  static void build_sequence_values(const std::vector<Array*> &arrays, SequenceValues &sv);
63  static void combine_sequence_values(SequenceValues &dep, const SequenceValues &indep);
64  static void add_index_column(const Shape &indep_shape, const Shape &dep_shape,
65  std::vector<Array*> &dep_vars);
66 
67 public:
69  {
70  setName("tabular");
71  setDescriptionString("The tabular() function transforms one or more arrays into a sequence.");
72  setUsageString("tabular()");
73  setRole("http://services.opendap.org/dap4/server-side-function/tabular");
74  setDocUrl("http://docs.opendap.org/index.php/Server_Side_Processing_Functions#tabular");
75  setFunction(libdap::TabularFunction::function_dap2_tabular);
76  // FIXME setFunction(libdap::TabularFunction::function_dap4_tabular);
77  setVersion("1.0");
78  }
79 
80  virtual ~TabularFunction()
81  {
82  }
83 };
84 
85 } // libdap namespace
static class NCMLUtil overview
friend class TabularFunctionTest
friend class Dap4_TabularFunctionTest