libdap
Updated for version 3.17.0
|
00001 00002 // -*- mode: c++; c-basic-offset:4 -*- 00003 00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00005 // Access Protocol. 00006 00007 // Copyright (c) 2014 OPeNDAP, Inc. 00008 // Author: James Gallagher <jgallagher@opendap.org> 00009 // 00010 // This library is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU Lesser General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 2.1 of the License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 // 00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00025 00026 #ifndef _D4RValue_h 00027 #define _D4RValue_h 00028 00029 #include <vector> 00030 00031 #include <dods-datatypes.h> 00032 #include <D4Function.h> 00033 00034 namespace libdap 00035 { 00036 00037 class BaseType; 00038 class D4Constant; 00039 class D4RValue; 00040 00041 class D4RValueList 00042 { 00043 private: 00044 std::vector<D4RValue *> d_rvalues; 00045 00046 public: 00047 typedef std::vector<D4RValue *>::iterator iter; 00048 00049 D4RValueList() { } 00050 D4RValueList(D4RValue *rv) { add_rvalue(rv); } 00051 00052 ~D4RValueList(); 00053 00054 void add_rvalue(D4RValue *rv) { 00055 d_rvalues.push_back(rv); 00056 } 00057 00058 D4RValue *get_rvalue(unsigned int i) { 00059 return d_rvalues.at(i); 00060 } 00061 00062 iter begin() { return d_rvalues.begin(); } 00063 iter end() { return d_rvalues.end(); } 00064 00065 unsigned int size() const { return d_rvalues.size(); } 00066 00067 }; 00068 00072 class D4RValue 00073 { 00074 private: 00075 BaseType *d_variable; // This is a weak pointer 00076 00077 D4Function d_func; // (weak) Pointer to a function returning BaseType * 00078 D4RValueList *d_args; // Strong pointer to arguments to the function; delete 00079 00080 BaseType *d_constant; // Strong pointer; delete 00081 00082 enum value_kind { 00083 unknown, 00084 basetype, 00085 function, 00086 constant 00087 }; 00088 00089 value_kind d_value_kind; 00090 00091 friend class D4RValueList; 00092 00093 public: 00094 D4RValue() : d_variable(0), d_func(0), d_args(0), d_constant(0), d_value_kind(unknown) { } 00095 00096 D4RValue(BaseType *btp) : d_variable(btp), d_func(0), d_args(0), d_constant(0), d_value_kind(basetype) { } 00097 D4RValue(D4Function f, D4RValueList *args) : d_variable(0), d_func(f), d_args(args), d_constant(0), d_value_kind(function) { } 00098 00099 D4RValue(unsigned long long ui); 00100 D4RValue(long long i); 00101 D4RValue(double r); 00102 D4RValue(std::string s); 00103 D4RValue(std::vector<dods_byte> &byte_args); 00104 D4RValue(std::vector<dods_int8> &byte_int8); 00105 D4RValue(std::vector<dods_uint16> &byte_uint16); 00106 D4RValue(std::vector<dods_int16> &byte_int16); 00107 D4RValue(std::vector<dods_uint32> &byte_uint32); 00108 D4RValue(std::vector<dods_int32> &byte_int32); 00109 D4RValue(std::vector<dods_uint64> &byte_uint64); 00110 D4RValue(std::vector<dods_int64> &byte_int64); 00111 D4RValue(std::vector<dods_float32> &byte_float32); 00112 D4RValue(std::vector<dods_float64> &byte_float64); 00113 00114 virtual ~D4RValue(); 00115 00116 // This is the call that will be used to return the value of a function. 00117 // jhrg 3/10/14 00118 BaseType *value(DMR &dmr); 00119 }; 00120 00121 } // namespace libdap 00122 #endif // _RValue_h