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) 2002,2003 OPeNDAP, Inc. 00008 // Author: James Gallagher <jgallagher@opendap.org> 00009 // Dan Holloway <dan@hollywood.gso.uri.edu> 00010 // Reza Nekovei <reza@intcomm.net> 00011 // 00012 // This library is free software; you can redistribute it and/or 00013 // modify it under the terms of the GNU Lesser General Public 00014 // License as published by the Free Software Foundation; either 00015 // version 2.1 of the License, or (at your option) any later version. 00016 // 00017 // This library is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 // Lesser General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU Lesser General Public 00023 // License along with this library; if not, write to the Free Software 00024 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00025 // 00026 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00027 00028 // (c) COPYRIGHT URI/MIT 1994-1999 00029 // Please read the full copyright statement in the file COPYRIGHT_URI. 00030 // 00031 // Authors: 00032 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu> 00033 // dan Dan Holloway <dan@hollywood.gso.uri.edu> 00034 // reza Reza Nekovei <reza@intcomm.net> 00035 00036 // Abstract base class for the variables in a dataset. This is used to store 00037 // the type-invariant information that describes a variable as given in the 00038 // DODS API. 00039 // 00040 // jhrg 9/6/94 00041 00042 #ifndef _basetype_h 00043 #define _basetype_h 1 00044 00045 #include <vector> 00046 #include <stack> 00047 #include <iostream> 00048 #include <string> 00049 00050 #include "AttrTable.h" 00051 00052 #include "InternalErr.h" 00053 00054 #include "dods-datatypes.h" 00055 #include "Type.h" 00056 00057 #include "DapObj.h" 00058 00059 using namespace std; 00060 00061 class Crc32; 00062 00063 namespace libdap 00064 { 00065 00066 class ConstraintEvaluator; 00067 00068 class DDS; 00069 class Marshaller; 00070 class UnMarshaller; 00071 00072 class Constructor; 00073 class XMLWrter; 00074 00075 class DMR; 00076 class D4Group; 00077 class XMLWriter; 00078 class D4StreamMarshaller; 00079 class D4StreamUnMarshaller; 00080 00081 class D4Attributes; 00082 00117 class BaseType : public DapObj 00118 { 00119 private: 00120 string d_name; // name of the instance 00121 Type d_type; // instance's type 00122 string d_dataset; // name of the dataset used to create this BaseType 00123 00124 bool d_is_read; // true if the value has been read 00125 bool d_is_send; // Is the variable in the projection? 00126 00127 // d_parent points to the Constructor or Vector which holds a particular 00128 // variable. It is null for simple variables. The Vector and Constructor 00129 // classes must maintain this variable. 00130 BaseType *d_parent; 00131 00132 // Attributes for this variable. Added 05/20/03 jhrg 00133 AttrTable d_attr; 00134 00135 D4Attributes *d_attributes; 00136 00137 bool d_is_dap4; // True if this is a DAP4 variable, false ... DAP2 00138 00139 // These are non-empty only for DAP4 variables. Added 9/27/12 jhrg 00140 00141 protected: 00142 // These were/are used for DAP2 CEs, but not for DAP4 ones 00143 bool d_in_selection; // Is the variable in the selection? 00144 bool d_is_synthesized; // true if the variable is synthesized 00145 00146 void m_duplicate(const BaseType &bt); 00147 00148 public: 00149 typedef stack<BaseType *> btp_stack; 00150 00151 // These ctors assume is_dap4 is false 00152 BaseType(const string &n, const Type &t, bool is_dap4 = false); 00153 BaseType(const string &n, const string &d, const Type &t, bool is_dap4 = false); 00154 00155 BaseType(const BaseType ©_from); 00156 virtual ~BaseType(); 00157 00158 virtual string toString(); 00159 00160 virtual BaseType *transform_to_dap4(D4Group *root, Constructor *container); 00161 00162 virtual void dump(ostream &strm) const ; 00163 00164 BaseType &operator=(const BaseType &rhs); 00165 00178 virtual void clear_local_data() { set_read_p(false); } 00179 00180 virtual bool is_dap4() const { return d_is_dap4; } 00181 virtual void set_is_dap4(const bool v) { d_is_dap4 = v;} 00182 00189 virtual BaseType *ptr_duplicate() = 0; 00190 00191 virtual string name() const; 00192 virtual void set_name(const string &n); 00193 virtual std::string FQN() const; 00194 00195 virtual Type type() const; 00196 virtual void set_type(const Type &t); 00197 virtual string type_name() const; 00198 00199 virtual string dataset() const ; 00200 00206 virtual int length() const { return 1; } 00207 00213 virtual void set_length(int) { } 00214 00215 virtual bool is_simple_type() const; 00216 virtual bool is_vector_type() const; 00217 virtual bool is_constructor_type() const; 00218 00219 virtual bool synthesized_p(); 00220 virtual void set_synthesized_p(bool state); 00221 00222 virtual int element_count(bool leaves = false); 00223 00224 virtual bool read_p(); 00225 virtual void set_read_p(bool state); 00226 00227 virtual bool send_p(); 00228 virtual void set_send_p(bool state); 00229 00230 virtual AttrTable &get_attr_table(); 00231 virtual void set_attr_table(const AttrTable &at); 00232 00233 // DAP4 attributes 00234 virtual D4Attributes *attributes(); 00235 virtual void set_attributes(D4Attributes *); 00236 virtual void set_attributes_nocopy(D4Attributes *); 00237 00238 virtual bool is_in_selection(); 00239 virtual void set_in_selection(bool state); 00240 00241 virtual void set_parent(BaseType *parent); 00242 virtual BaseType *get_parent() const; 00243 00244 virtual void transfer_attributes(AttrTable *at); 00245 00246 // I put this comment here because the version in BaseType.cc does not 00247 // include the exact_match or s variables since they are not used. Doxygen 00248 // was gaging on the comment. 00249 00280 virtual BaseType *var(const string &name = "", bool exact_match = true, btp_stack *s = 0); 00281 virtual BaseType *var(const string &name, btp_stack &s); 00282 00283 virtual void add_var(BaseType *bt, Part part = nil); 00284 virtual void add_var_nocopy(BaseType *bt, Part part = nil); 00285 00286 virtual bool read(); 00287 00288 virtual bool check_semantics(string &msg, bool all = false); 00289 00290 virtual bool ops(BaseType *b, int op); 00291 00292 virtual unsigned int width(bool constrained = false) const; 00293 00294 virtual void print_decl(FILE *out, string space = " ", 00295 bool print_semi = true, 00296 bool constraint_info = false, 00297 bool constrained = false); 00298 00299 virtual void print_xml(FILE *out, string space = " ", 00300 bool constrained = false); 00301 00302 virtual void print_decl(ostream &out, string space = " ", 00303 bool print_semi = true, 00304 bool constraint_info = false, 00305 bool constrained = false); 00306 00307 virtual void print_xml(ostream &out, string space = " ", 00308 bool constrained = false); 00309 00310 virtual void print_xml_writer(XMLWriter &xml, bool constrained = false); 00311 00312 virtual void print_dap4(XMLWriter &xml, bool constrained = false); 00313 00316 #if 0 00317 00328 virtual unsigned int width(bool constrained = false) = 0; 00329 #endif 00330 00350 virtual unsigned int buf2val(void **val) = 0; 00351 00381 virtual unsigned int val2buf(void *val, bool reuse = false) = 0; 00382 00397 virtual void intern_data(ConstraintEvaluator &eval, DDS &dds); 00398 00442 virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true); 00443 00444 #if 0 00445 00465 virtual bool serialize_no_release(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true) { 00466 return serialize(eval, dds, m, ce_eval); 00467 } 00468 #endif 00469 00476 virtual void compute_checksum(Crc32 &checksum) = 0; 00477 00478 virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/); 00479 00493 virtual void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter = false); 00494 00495 #if 0 00496 00514 virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false) { 00515 serialize(m, dmr, filter); 00516 } 00517 #endif 00518 00543 virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false); 00544 00551 virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr); 00552 00568 virtual void print_val(FILE *out, string space = "", 00569 bool print_decl_p = true); 00570 00585 virtual void print_val(ostream &out, string space = "", 00586 bool print_decl_p = true) = 0; 00588 }; 00589 00590 } // namespace libdap 00591 00592 #endif // _basetype_h