bes  Updated for version 3.20.6
MakeMaskFunction.h
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) 2015 OPeNDAP, Inc.
7 // Authors: Dan Holloway <dholloway@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 #include <dods-datatypes.h>
27 
28 namespace libdap {
29 class BaseType;
30 class Array;
31 class DDS;
32 }
33 
34 typedef struct
35 {
36  int size;
37  std::string name;
38  int offset;
39 } MaskDIM;
40 
41 namespace functions {
42 
43 // Added here so we can call it in unit tests
44 int find_value_index(double value, const std::vector<double> &map);
45 std::vector<int> find_value_indices(const std::vector<double> &values,
46  const std::vector< std::vector<double> > &maps);
47 bool all_indices_valid(std::vector<int> indices);
48 template<typename T>
49 void make_mask_helper(const std::vector<libdap::Array*> dims, libdap::Array *tuples, std::vector<libdap::dods_byte> &mask);
50 
51 void function_dap2_make_mask(int argc, libdap::BaseType *argv[], libdap::DDS &dds, libdap::BaseType **btpp);
52 
58 class MakeMaskFunction: public libdap::ServerFunction
59 {
60 public:
62  {
63  setName("make_mask");
64  setDescriptionString("The make_mask() function reads a number of dim_names, followed by a set of dim value tuples and builds a DAP Array object.");
65  //setUsageString("make_mask(type,dim0,dim1,..dimN,dim0_value,dim1_value,...,dimN_value)");
66  setRole("http://services.opendap.org/dap4/server-side-function/make_mask");
67  setDocUrl("http://docs.opendap.org/index.php/Server_Side_Processing_Functions#make_mask");
68  setFunction(function_dap2_make_mask);
69  //setFunction(function_make_dap4_mask);
70  setVersion("1.0");
71  }
72  virtual ~MakeMaskFunction()
73  {
74  }
75 };
76 
77 } // functions namespace
MaskDIM
Definition: MakeMaskFunction.h:34
libdap
Definition: BESDapFunctionResponseCache.h:35
functions::MakeMaskFunction
Definition: MakeMaskFunction.h:58