libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
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 <string>
30#include <vector>
31
32#include <D4Function.h>
33#include <dods-datatypes.h>
34
35namespace libdap {
36
37class BaseType;
38class D4RValue;
39
40// Factory class to build RValue objects. User by the parser/ce-evaluator
41D4RValue *D4RValueFactory(std::string cpps);
42
44private:
45 std::vector<D4RValue *> d_rvalues;
46
47 void m_duplicate(const D4RValueList &src);
48
49public:
50 typedef std::vector<D4RValue *>::iterator iter;
51
53 D4RValueList(const D4RValueList &src) { m_duplicate(src); }
55
56 virtual ~D4RValueList();
57
59 if (this == &rhs)
60 return *this;
61 m_duplicate(rhs);
62 return *this;
63 }
64
65 void add_rvalue(D4RValue *rv) { d_rvalues.push_back(rv); }
66
67 D4RValue *get_rvalue(unsigned int i) { return d_rvalues.at(i); }
68
69 iter begin() { return d_rvalues.begin(); }
70 iter end() { return d_rvalues.end(); }
71
72 unsigned int size() const { return d_rvalues.size(); }
73};
74
79class D4RValue {
80public:
82
83private:
84 BaseType *d_variable; // This is a weak pointer; do not delete
85
86 D4Function d_func; // (weak) pointer to a function returning BaseType *
87 D4RValueList *d_args; // pointer to arguments to the function; delete
88
89 BaseType *d_constant; // pointer; delete.
90
91 value_kind d_value_kind;
92
94 void m_duplicate(const D4RValue &src);
95
96 friend class D4RValueList;
97
98public:
99 D4RValue() : d_variable(0), d_func(0), d_args(0), d_constant(0), d_value_kind(unknown) {}
100 D4RValue(const D4RValue &src) { m_duplicate(src); }
101 D4RValue(BaseType *btp) : d_variable(btp), d_func(0), d_args(0), d_constant(0), d_value_kind(basetype) {}
103 : d_variable(0), d_func(f), d_args(args), d_constant(0), d_value_kind(function) {}
104
105 D4RValue(unsigned long long ui);
106 D4RValue(long long i);
107 D4RValue(double r);
108 D4RValue(std::string s);
109 D4RValue(std::vector<dods_byte> &byte_args);
110 D4RValue(std::vector<dods_int8> &byte_int8);
111 D4RValue(std::vector<dods_uint16> &byte_uint16);
112 D4RValue(std::vector<dods_int16> &byte_int16);
113 D4RValue(std::vector<dods_uint32> &byte_uint32);
114 D4RValue(std::vector<dods_int32> &byte_int32);
115 D4RValue(std::vector<dods_uint64> &byte_uint64);
116 D4RValue(std::vector<dods_int64> &byte_int64);
117 D4RValue(std::vector<dods_float32> &byte_float32);
118 D4RValue(std::vector<dods_float64> &byte_float64);
119
120 virtual ~D4RValue();
121
123 if (this == &rhs)
124 return *this;
125
126 m_duplicate(rhs);
127
128 return *this;
129 }
130
139 value_kind get_kind() const { return d_value_kind; }
140
141 // This is the call that will be used to return the value of a function.
142 // jhrg 3/10/14
143 virtual BaseType *value(DMR &dmr);
144 // And this optimizes value() for filters, where functions are not supported.
145 virtual BaseType *value();
146};
147
148} // namespace libdap
149#endif // _RValue_h
The basic data type for the DODS DAP types.
Definition BaseType.h:118
void add_rvalue(D4RValue *rv)
Definition D4RValue.h:65
D4RValue * get_rvalue(unsigned int i)
Definition D4RValue.h:67
std::vector< D4RValue * >::iterator iter
Definition D4RValue.h:50
unsigned int size() const
Definition D4RValue.h:72
D4RValueList(D4RValue *rv)
Definition D4RValue.h:54
D4RValueList(const D4RValueList &src)
Definition D4RValue.h:53
virtual ~D4RValueList()
Definition D4RValue.cc:63
D4RValueList & operator=(const D4RValueList &rhs)
Definition D4RValue.h:58
value_kind get_kind() const
What kind of thing holds the value Values in DAP4 constraints are either constants,...
Definition D4RValue.h:139
virtual BaseType * value()
Get the value for a RValue object.
Definition D4RValue.cc:272
friend class D4RValueList
Definition D4RValue.h:96
virtual ~D4RValue()
Definition D4RValue.cc:181
D4RValue(D4Function f, D4RValueList *args)
Definition D4RValue.h:102
D4RValue(BaseType *btp)
Definition D4RValue.h:101
D4RValue & operator=(D4RValue &rhs)
Definition D4RValue.h:122
D4RValue(const D4RValue &src)
Definition D4RValue.h:100
top level DAP object to house generic methods
Definition AISConnect.cc:30
BaseType *(* D4Function)(D4RValueList *, DMR &)
Definition D4Function.h:41
D4RValue * D4RValueFactory(std::string cpps)
Build an appropriate RValue.
Definition D4RValue.cc:197