libdap++  Updated for version 3.14.0
D4RValue.h
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2014 OPeNDAP, Inc.
8 // Author: 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 #ifndef _D4RValue_h
27 #define _D4RValue_h
28 
29 #include <vector>
30 
31 #include <dods-datatypes.h>
32 #include <D4Function.h>
33 
34 namespace libdap
35 {
36 
37 class BaseType;
38 class D4Constant;
39 class D4RValue;
40 
42 {
43 private:
44  std::vector<D4RValue *> d_rvalues;
45 
46 public:
47  typedef std::vector<D4RValue *>::iterator iter;
48 
51 
52  ~D4RValueList();
53 
54  void add_rvalue(D4RValue *rv) {
55  d_rvalues.push_back(rv);
56  }
57 
58  D4RValue *get_rvalue(unsigned int i) {
59  return d_rvalues.at(i);
60  }
61 
62  iter begin() { return d_rvalues.begin(); }
63  iter end() { return d_rvalues.end(); }
64 
65  unsigned int size() const { return d_rvalues.size(); }
66 
67 };
68 
72 class D4RValue
73 {
74 private:
75  BaseType *d_variable; // This is a weak pointer
76 
77  D4Function d_func; // (weak) Pointer to a function returning BaseType *
78  D4RValueList *d_args; // Strong pointer to arguments to the function; delete
79 
80  BaseType *d_constant; // Strong pointer; delete
81 
82  enum value_kind {
83  unknown,
84  basetype,
85  function,
86  constant
87  };
88 
89  value_kind d_value_kind;
90 
91  friend class D4RValueList;
92 
93 public:
94  D4RValue() : d_variable(0), d_func(0), d_args(0), d_constant(0), d_value_kind(unknown) { }
95 
96  D4RValue(BaseType *btp) : d_variable(btp), d_func(0), d_args(0), d_constant(0), d_value_kind(basetype) { }
97  D4RValue(D4Function f, D4RValueList *args) : d_variable(0), d_func(f), d_args(args), d_constant(0), d_value_kind(function) { }
98 
99  D4RValue(unsigned long long ui);
100  D4RValue(long long i);
101  D4RValue(double r);
102  D4RValue(std::string s);
103  D4RValue(std::vector<dods_byte> &byte_args);
104  D4RValue(std::vector<dods_int8> &byte_int8);
105  D4RValue(std::vector<dods_uint16> &byte_uint16);
106  D4RValue(std::vector<dods_int16> &byte_int16);
107  D4RValue(std::vector<dods_uint32> &byte_uint32);
108  D4RValue(std::vector<dods_int32> &byte_int32);
109  D4RValue(std::vector<dods_uint64> &byte_uint64);
110  D4RValue(std::vector<dods_int64> &byte_int64);
111  D4RValue(std::vector<dods_float32> &byte_float32);
112  D4RValue(std::vector<dods_float64> &byte_float64);
113 
114  virtual ~D4RValue();
115 
116  // This is the call that will be used to return the value of a function.
117  // jhrg 3/10/14
118  BaseType *value(DMR &dmr);
119 };
120 
121 } // namespace libdap
122 #endif // _RValue_h
unsigned int size() const
Definition: D4RValue.h:65
D4RValue * get_rvalue(unsigned int i)
Definition: D4RValue.h:58
std::vector< D4RValue * >::iterator iter
Definition: D4RValue.h:47
D4RValue(BaseType *btp)
Definition: D4RValue.h:96
virtual ~D4RValue()
Definition: D4RValue.cc:180
D4RValue(D4Function f, D4RValueList *args)
Definition: D4RValue.h:97
BaseType * value(DMR &dmr)
Definition: D4RValue.cc:198
D4RValueList(D4RValue *rv)
Definition: D4RValue.h:50
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
void add_rvalue(D4RValue *rv)
Definition: D4RValue.h:54
BaseType *(* D4Function)(D4RValueList *, DMR &)
Definition: D4Function.h:42