libdap Updated for version 3.20.9
libdap4 is an implementation of OPeNDAP's DAP protocol.
Constructor.cc
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) 2002,2003 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// (c) COPYRIGHT URI/MIT 1995-1999
27// Please read the full copyright statement in the file COPYRIGHT_URI.
28//
29// Authors:
30// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31
32
33#include "config.h"
34
35//#define DODS_DEBUG
36
37#include <string>
38#include <sstream>
39#include <algorithm>
40#include <functional>
41
42#include <stdint.h>
43
44#include "crc.h"
45
46#include "Constructor.h"
47#include "Grid.h"
48
49#include "DMR.h"
50#include "XMLWriter.h"
51#include "D4StreamMarshaller.h"
52#include "D4StreamUnMarshaller.h"
53#include "D4Group.h"
54
55#include "D4Attributes.h"
56
57#include "escaping.h"
58#include "util.h"
59#include "Error.h"
60#include "InternalErr.h"
61#include "DapIndent.h"
62
63// #define DODS_DEBUG 1
64#include "debug.h"
65
66using namespace std;
67
68namespace libdap {
69
70// Private member functions
71
72void
73Constructor::m_duplicate(const Constructor &c)
74{
75 DBG(cerr << "In Constructor::m_duplicate for " << c.name() << endl);
76 // Clear out any spurious vars in Constructor::d_vars
77 // Moved from Grid::m_duplicate. jhrg 4/3/13
78 d_vars.clear(); // [mjohnson 10 Sep 2009]
79
80 Vars_citer i = c.d_vars.begin();
81 while (i != c.d_vars.end()) {
82 BaseType *btp = (*i++)->ptr_duplicate();
83 btp->set_parent(this);
84 d_vars.push_back(btp);
85 }
86
87 DBG(cerr << "Exiting Constructor::m_duplicate for " << c.name() << endl);
88}
89
90// Public member functions
91
92Constructor::Constructor(const string &name, const Type &type, bool is_dap4)
93 : BaseType(name, type, is_dap4)
94{}
95
106Constructor::Constructor(const string &name, const string &dataset, const Type &type, bool is_dap4)
107 : BaseType(name, dataset, type, is_dap4)
108{}
109
110Constructor::Constructor(const Constructor &rhs) : BaseType(rhs), d_vars(0)
111{
112 DBG(cerr << "In Constructor::copy_ctor for " << rhs.name() << endl);
113 m_duplicate(rhs);
114}
115
116Constructor::~Constructor()
117{
118 Vars_iter i = d_vars.begin();
119 while (i != d_vars.end()) {
120 delete *i++;
121 }
122}
123
124Constructor &
125Constructor::operator=(const Constructor &rhs)
126{
127 DBG(cerr << "Entering Constructor::operator=" << endl);
128 if (this == &rhs)
129 return *this;
130
131 dynamic_cast<BaseType &>(*this) = rhs; // run BaseType=
132
133 m_duplicate(rhs);
134
135 DBG(cerr << "Exiting Constructor::operator=" << endl);
136 return *this;
137}
138
139// A public method, but just barely...
140void
142{
143 DBG(cerr << __func__ << "() - BEGIN (name:"<< name() <<
144 ")(type:"<< type_name()<<
145 ")(root:'"<< root->name()<<"':"<<(void*)root <<
146 ")(dest:'"<< dest->name()<<"':"<< (void *) dest<< ")"
147 << endl;);
148
149 for (Constructor::Vars_citer i = var_begin(), e = var_end(); i != e; ++i) {
150 BaseType *d4_var = dest->var((*i)->name());
151 // Don't add duplicate variables. We have to make this check
152 // because some of the child variables may add arrays
153 // to the root object. For example, this happens in
154 // Grid with the Map Arrays - ndp - 05/08/17
155 if(!d4_var){
156 /*
157 BaseType *new_var = (*i)->transform_to_dap4(root, dest);
158 if (new_var) { // Might be a Grid; see the comment in BaseType::transform_to_dap4()
159 new_var->set_parent(dest);
160 dest->add_var_nocopy(new_var);
161 }
162 */
163 DBG(cerr << __func__ << "() - Transforming variable: '" <<
164 (*i)->name() << "'" << endl; );
165 (*i)->transform_to_dap4(root /*group*/, dest /*container*/);
166 }
167 else {
168 DBG(cerr << __func__ << "() - Skipping variable: " <<
169 d4_var->type_name() << " " << d4_var->name() << " because a variable with" <<
170 " this name already exists in the root group." << endl; );
171 }
172 }
174 dest->set_is_dap4(true);
175 DBG(cerr << __func__ << "() - END (name:"<< name() << ")(type:"<< type_name()<< ")" << endl;);
176}
177
178
179
180string
182{
183 if (get_parent() == 0)
184 return name();
185 else if (get_parent()->type() == dods_group_c)
186 return get_parent()->FQN() + name();
187 else if (get_parent()->type() == dods_array_c)
188 return get_parent()->FQN();
189 else
190 return get_parent()->FQN() + "." + name();
191}
192
193int
195{
196 if (!leaves)
197 return d_vars.size();
198 else {
199 int i = 0;
200 for (Vars_iter j = d_vars.begin(); j != d_vars.end(); j++) {
201 i += (*j)->element_count(leaves);
202 }
203 return i;
204 }
205}
206
207void
209{
210 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
211 (*i)->set_send_p(state);
212 }
213
215}
216
217void
219{
220 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
221 (*i)->set_read_p(state);
222 }
223
225}
226
227#if 0
228// TODO Recode to use width(bool). Bur see comments in BaseType.h
229unsigned int
231{
232 unsigned int sz = 0;
233
234 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
235 sz += (*i)->width();
236 }
237
238 return sz;
239}
240#endif
248unsigned int
249Constructor::width(bool constrained) const
250{
251 unsigned int sz = 0;
252
253 for (Vars_citer i = d_vars.begin(); i != d_vars.end(); i++) {
254 if (constrained) {
255 if ((*i)->send_p())
256 sz += (*i)->width(constrained);
257 }
258 else {
259 sz += (*i)->width(constrained);
260 }
261 }
262
263 return sz;
264}
265
266BaseType *
267Constructor::var(const string &name, bool exact_match, btp_stack *s)
268{
269 string n = www2id(name);
270
271 if (exact_match)
272 return m_exact_match(n, s);
273 else
274 return m_leaf_match(n, s);
275}
276
278BaseType *
279Constructor::var(const string &n, btp_stack &s)
280{
281 // This should probably be removed. The BES code should remove web encoding
282 // with the possible exception of spaces. jhrg 11/25/13
283 string name = www2id(n);
284
285 BaseType *btp = m_exact_match(name, &s);
286 if (btp)
287 return btp;
288
289 return m_leaf_match(name, &s);
290}
291
292// Protected method
293BaseType *
294Constructor::m_leaf_match(const string &name, btp_stack *s)
295{
296 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
297 if ((*i)->name() == name) {
298 if (s) {
299 DBG(cerr << "Pushing " << this->name() << endl);
300 s->push(static_cast<BaseType *>(this));
301 }
302 return *i;
303 }
304 if ((*i)->is_constructor_type()) {
305 BaseType *btp = (*i)->var(name, false, s);
306 if (btp) {
307 if (s) {
308 DBG(cerr << "Pushing " << this->name() << endl);
309 s->push(static_cast<BaseType *>(this));
310 }
311 return btp;
312 }
313 }
314 }
315
316 return 0;
317}
318
319// Protected method
320BaseType *
321Constructor::m_exact_match(const string &name, btp_stack *s)
322{
323 // Look for name at the top level first.
324 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
325 if ((*i)->name() == name) {
326 if (s)
327 s->push(static_cast<BaseType *>(this));
328
329 return *i;
330 }
331 }
332
333 // If it was not found using the simple search, look for a dot and
334 // search the hierarchy.
335 string::size_type dot_pos = name.find("."); // zero-based index of `.'
336 if (dot_pos != string::npos) {
337 string aggregate = name.substr(0, dot_pos);
338 string field = name.substr(dot_pos + 1);
339
340 BaseType *agg_ptr = var(aggregate);
341 if (agg_ptr) {
342 if (s)
343 s->push(static_cast<BaseType *>(this));
344
345 return agg_ptr->var(field, true, s); // recurse
346 }
347 else
348 return 0; // qualified names must be *fully* qualified
349 }
350
351 return 0;
352}
353
355Constructor::Vars_iter
357{
358 return d_vars.begin() ;
359}
360
363Constructor::Vars_iter
365{
366 return d_vars.end() ;
367}
368
370Constructor::Vars_riter
372{
373 return d_vars.rbegin();
374}
375
378Constructor::Vars_riter
380{
381 return d_vars.rend();
382}
383
387Constructor::Vars_iter
389{
390 return d_vars.begin() + i;
391}
392
396BaseType *
398{
399 return *(d_vars.begin() + i);
400}
401
406void
408{
409 // Jose Garcia
410 // Passing and invalid pointer to an object is a developer's error.
411 if (!bt)
412 throw InternalErr(__FILE__, __LINE__, "The BaseType parameter cannot be null.");
413#if 0
414 if (bt->is_dap4_only_type())
415 throw InternalErr(__FILE__, __LINE__, "Attempt to add a DAP4 type to a DAP2 Structure.");
416#endif
417 // Jose Garcia
418 // Now we add a copy of bt so the external user is able to destroy bt as
419 // he/she wishes. The policy is: "If it is allocated outside, it is
420 // deallocated outside, if it is allocated inside, it is deallocated
421 // inside"
422 BaseType *btp = bt->ptr_duplicate();
423 btp->set_parent(this);
424 d_vars.push_back(btp);
425}
426
431void
433{
434 if (!bt)
435 throw InternalErr(__FILE__, __LINE__, "The BaseType parameter cannot be null.");
436#if 0
437 if (bt->is_dap4_only_type())
438 throw InternalErr(__FILE__, __LINE__, "Attempt to add a DAP4 type to a DAP2 Structure.");
439#endif
440 bt->set_parent(this);
441 d_vars.push_back(bt);
442}
443
447void
448Constructor::del_var(const string &n)
449{
450 // TODO remove_if? find_if?
451 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
452 if ((*i)->name() == n) {
453 BaseType *bt = *i ;
454 d_vars.erase(i) ;
455 delete bt ; bt = 0;
456 return;
457 }
458 }
459}
460
461void
462Constructor::del_var(Vars_iter i)
463{
464 if (*i != 0) {
465 BaseType *bt = *i;
466 d_vars.erase(i);
467 delete bt;
468 }
469}
470
477{
478 DBG(cerr << "Entering Constructor::read..." << endl);
479 if (!read_p()) {
480 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
481 (*i)->read();
482 }
483 set_read_p(true);
484 }
485
486 return false;
487}
488
489void
491{
492 DBG(cerr << "Constructor::intern_data: " << name() << endl);
493 if (!read_p())
494 read(); // read() throws Error and InternalErr
495
496 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
497 if ((*i)->send_p()) {
498 (*i)->intern_data(eval, dds);
499 }
500 }
501}
502
503bool
505{
506#if USE_LOCAL_TIMEOUT_SCHEME
507 dds.timeout_on();
508#endif
509 if (!read_p())
510 read(); // read() throws Error and InternalErr
511
512 if (ce_eval && !eval.eval_selection(dds, dataset()))
513 return true;
514#if USE_LOCAL_TIMEOUT_SCHEME
515 dds.timeout_off();
516#endif
517 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
518 if ((*i)->send_p()) {
519#ifdef CHECKSUMS
520 XDRStreamMarshaller *sm = dynamic_cast<XDRStreamMarshaller*>(&m);
521 if (sm && sm->checksums() && (*i)->type() != dods_structure_c && (*i)->type() != dods_grid_c)
522 sm->reset_checksum();
523
524 (*i)->serialize(eval, dds, m, false);
525
526 if (sm && sm->checksums() && (*i)->type() != dods_structure_c && (*i)->type() != dods_grid_c)
527 sm->get_checksum();
528#else
529 // (*i)->serialize(eval, dds, m, false);
530 // Only Sequence and Vector run the evaluator.
531 (*i)->serialize(eval, dds, m, true);
532#endif
533 }
534 }
535
536 return true;
537}
538
539bool
541{
542 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
543 (*i)->deserialize(um, dds, reuse);
544 }
545
546 return false;
547}
548
549void
551{
552 throw InternalErr(__FILE__, __LINE__, "Computing a checksum alone is not supported for Constructor types.");
553}
554
555void
556Constructor::intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator & eval*/)
557{
558 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
559 if ((*i)->send_p()) {
560 (*i)->intern_data(/*checksum, dmr, eval*/);
561 }
562 }
563}
564
565
577void
578Constructor::serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter)
579{
580#if 1
581 // Not used for the same reason the equivalent code in D4Group::serialize()
582 // is not used. Fail for D4Sequence and general issues with memory use.
583 //
584 // Revisit this - I had to uncomment this to get the netcdf_handler code
585 // to work - it relies on having NCStructure::read() called. The D4Sequence
586 // ::serialize() method calls read_next_instance(). What seems to be happening
587 // is that this call to read gets the first set of values, but does not store
588 // them; the call to serialize then runs the D4Sequence::serialize() method that
589 // _does_ read all of the sequence data and then serialize it. However, the first
590 // sequence instance is missing...
591 if (!read_p())
592 read(); // read() throws Error
593#endif
594#if 0
595 // place holder for now. There may be no need for this; only Array and Seq?
596 // jhrg 9/6/13
597 if (filter && !eval.eval_selection(dmr, dataset()))
598 return true;
599#endif
600
601 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
602 if ((*i)->send_p()) {
603 (*i)->serialize(m, dmr, /*eval,*/ filter);
604 }
605 }
606}
607
608void
610{
611 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
612 (*i)->deserialize(um, dmr);
613 }
614}
615
616void
617Constructor::print_decl(FILE *out, string space, bool print_semi,
618 bool constraint_info, bool constrained)
619{
620 ostringstream oss;
621 print_decl(oss, space, print_semi, constraint_info, constrained);
622 fwrite(oss.str().data(), sizeof(char), oss.str().length(), out);
623}
624
625void
626Constructor::print_decl(ostream &out, string space, bool print_semi,
627 bool constraint_info, bool constrained)
628{
629 if (constrained && !send_p())
630 return;
631
632 out << space << type_name() << " {\n" ;
633 for (Vars_citer i = d_vars.begin(); i != d_vars.end(); i++) {
634 (*i)->print_decl(out, space + " ", true, constraint_info, constrained);
635 }
636 out << space << "} " << id2www(name()) ;
637
638 if (constraint_info) { // Used by test drivers only.
639 if (send_p())
640 out << ": Send True";
641 else
642 out << ": Send False";
643 }
644
645 if (print_semi)
646 out << ";\n" ;
647}
648
649void
650Constructor::print_val(FILE *out, string space, bool print_decl_p)
651{
652 ostringstream oss;
653 print_val(oss, space, print_decl_p);
654 fwrite(oss.str().data(), sizeof(char), oss.str().length(), out);
655}
656
657void
658Constructor::print_val(ostream &out, string space, bool print_decl_p)
659{
660 if (print_decl_p) {
661 print_decl(out, space, false);
662 out << " = " ;
663 }
664
665 out << "{ " ;
666 for (Vars_citer i = d_vars.begin(), e = d_vars.end(); i != e;
667 i++, (void)(i != e && out << ", ")) {
668
669 DBG(cerr << (*i)->name() << " isa " << (*i)->type_name() << endl);
670
671 (*i)->print_val(out, "", false);
672 }
673
674 out << " }" ;
675
676 if (print_decl_p)
677 out << ";\n" ;
678}
679
683void
684Constructor::print_xml(FILE *out, string space, bool constrained)
685{
686 XMLWriter xml(space);
687 print_xml_writer(xml, constrained);
688 fwrite(xml.get_doc(), sizeof(char), xml.get_doc_size(), out);
689}
690
694void
695Constructor::print_xml(ostream &out, string space, bool constrained)
696{
697 XMLWriter xml(space);
698 print_xml_writer(xml, constrained);
699 out << xml.get_doc();
700}
701
702class PrintFieldXMLWriter : public unary_function<BaseType *, void>
703{
704 XMLWriter &d_xml;
705 bool d_constrained;
706public:
707 PrintFieldXMLWriter(XMLWriter &x, bool c)
708 : d_xml(x), d_constrained(c)
709 {}
710
711 void operator()(BaseType *btp)
712 {
713 btp->print_xml_writer(d_xml, d_constrained);
714 }
715};
716
717void
719{
720 if (constrained && !send_p())
721 return;
722
723 if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*)type_name().c_str()) < 0)
724 throw InternalErr(__FILE__, __LINE__, "Could not write " + type_name() + " element");
725
726 if (!name().empty())
727 if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "name", (const xmlChar*)name().c_str()) < 0)
728 throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
729
730 // DAP2 prints attributes first. For some reason we decided that DAP4 should
731 // print them second. No idea why... jhrg 8/15/14
732 if (!is_dap4() && get_attr_table().get_size() > 0)
734
735 bool has_variables = (var_begin() != var_end());
736 if (has_variables)
737 for_each(var_begin(), var_end(), PrintFieldXMLWriter(xml, constrained));
738
739 if (is_dap4())
740 attributes()->print_dap4(xml);
741
742#if 0
743 // Moved up above so that the DDX tests for various handles will still work.
744 // jhrg 8/15/14
745 if (!is_dap4() && get_attr_table().get_size() > 0)
747#endif
748
749 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
750 throw InternalErr(__FILE__, __LINE__, "Could not end " + type_name() + " element");
751}
752
753class PrintDAP4FieldXMLWriter : public unary_function<BaseType *, void>
754{
755 XMLWriter &d_xml;
756 bool d_constrained;
757public:
758 PrintDAP4FieldXMLWriter(XMLWriter &x, bool c) : d_xml(x), d_constrained(c) {}
759
760 void operator()(BaseType *btp)
761 {
762 btp->print_dap4(d_xml, d_constrained);
763 }
764};
765
766
767void
768Constructor::print_dap4(XMLWriter &xml, bool constrained)
769{
770 if (constrained && !send_p())
771 return;
772
773 if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*)type_name().c_str()) < 0)
774 throw InternalErr(__FILE__, __LINE__, "Could not write " + type_name() + " element");
775
776 if (!name().empty())
777 if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "name", (const xmlChar*)name().c_str()) < 0)
778 throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
779
780 bool has_variables = (var_begin() != var_end());
781 if (has_variables)
782 for_each(var_begin(), var_end(), PrintDAP4FieldXMLWriter(xml, constrained));
783
784 attributes()->print_dap4(xml);
785
786 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
787 throw InternalErr(__FILE__, __LINE__, "Could not end " + type_name() + " element");
788}
789
790
791bool
792Constructor::check_semantics(string &msg, bool all)
793{
795 return false;
796
797 if (!unique_names(d_vars, name(), type_name(), msg))
798 return false;
799
800 if (all)
801 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
802 if (!(*i)->check_semantics(msg, true)) {
803 return false;
804 }
805 }
806
807 return true;
808}
809
822bool
824{
825 return false;
826}
827
833void
835{
836 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
837 (*i)->set_in_selection(state);
838 }
839
841}
842
843
845{
846 AttrTable *at = at_container->get_attr_table(name());
847 DBG(cerr << "Constructor::transfer_attributes() - processing " << name() << "' addr: "<< (void*) at << endl);
848 if (at) {
849 BaseType::transfer_attributes(at_container);
850 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
851 BaseType *bt = (*i);
852 bt->transfer_attributes(at);
853 }
854
855 }
856}
857
858AttrTable *
859Constructor::make_dropped_vars_attr_table(vector<BaseType *> *dropped_vars) {
860 DBG( cerr << __func__ << "() - BEGIN" << endl;);
861
862 AttrTable *dv_table = NULL;
863 if(!dropped_vars->empty()){
864 dv_table = new AttrTable;
865 dv_table->set_name("dap4:dropped_members");
866 vector<BaseType *>::iterator dvIter = dropped_vars->begin();
867 vector<BaseType *>::iterator dvEnd = dropped_vars->end();
868 unsigned int i = 0;
869 for( ; dvIter!=dvEnd ; dvIter++, i++){
870 BaseType *bt = (*dvIter);
871 AttrTable *bt_attr_table = new AttrTable(bt->get_attr_table());
872 bt_attr_table->set_name(bt->name());
873 string type_name = bt->type_name();
874 if(bt->is_vector_type()){
875 Array *array = dynamic_cast <Array *>(bt);
876 if(array){
877 type_name = array->prototype()->type_name();
878 DBG( cerr << __func__ << "() - The variable " << bt->name() << " is an Array of '"<< type_name << "'" << endl;);
879 Array::Dim_iter d_iter = array->dim_begin();
880 Array::Dim_iter end = array->dim_end();
881 for( ; d_iter< end ; d_iter++){
882
883 ostringstream dim_size;
884 dim_size << (*d_iter).size;
885 bt_attr_table->append_attr(
886 "array_dimensions",
887 AttrType_to_String(Attr_uint32),
888 dim_size.str());
889 }
890 }
891 }
892 bt_attr_table->append_attr("dap4:type","String", type_name);
893 dv_table->append_container(bt_attr_table,bt_attr_table->get_name());
894 // Clear entry now that we're done.
895 (*dvIter) = 0;
896 }
897 }
898 DBG( cerr << __func__ << "() - END " << endl;);
899 return dv_table;
900
901}
902
903
912void
913Constructor::dump(ostream &strm) const
914{
915 strm << DapIndent::LMarg << "Constructor::dump - ("
916 << (void *)this << ")" << endl ;
917 DapIndent::Indent() ;
918 BaseType::dump(strm) ;
919 strm << DapIndent::LMarg << "vars: " << endl ;
920 DapIndent::Indent() ;
921 Vars_citer i = d_vars.begin() ;
922 Vars_citer ie = d_vars.end() ;
923 for (; i != ie; i++) {
924 (*i)->dump(strm) ;
925 }
926 DapIndent::UnIndent() ;
927 DapIndent::UnIndent() ;
928}
929
930} // namespace libdap
931
Definition: crc.h:77
A multidimensional array of identical data types.
Definition: Array.h:113
std::vector< dimension >::iterator Dim_iter
Definition: Array.h:206
Contains the attributes for a dataset.
Definition: AttrTable.h:143
virtual void set_name(const string &n)
Set the name of this attribute table.
Definition: AttrTable.cc:245
virtual AttrTable * get_attr_table(const string &name)
Get an attribute container.
Definition: AttrTable.cc:607
virtual unsigned int append_attr(const string &name, const string &type, const string &value)
Add an attribute to the table.
Definition: AttrTable.cc:307
virtual string get_name() const
Get the name of this attribute table.
Definition: AttrTable.cc:238
void print_xml_writer(XMLWriter &xml)
Definition: AttrTable.cc:1425
The basic data type for the DODS DAP types.
Definition: BaseType.h:118
virtual string type_name() const
Returns the type of the class instance as a string.
Definition: BaseType.cc:379
virtual AttrTable & get_attr_table()
Definition: BaseType.cc:582
virtual string name() const
Returns the name of the class instance.
Definition: BaseType.cc:320
virtual void set_in_selection(bool state)
Definition: BaseType.cc:718
virtual BaseType * get_parent() const
Definition: BaseType.cc:751
virtual bool read_p()
Has this variable been read?
Definition: BaseType.cc:480
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: BaseType.cc:516
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition: BaseType.cc:358
virtual void set_parent(BaseType *parent)
Definition: BaseType.cc:733
virtual bool is_vector_type() const
Returns true if the instance is a vector (i.e., array) type variable.
Definition: BaseType.cc:402
virtual D4Attributes * attributes()
Definition: BaseType.cc:599
virtual std::string FQN() const
Definition: BaseType.cc:332
virtual bool send_p()
Should this variable be sent?
Definition: BaseType.cc:554
virtual void set_send_p(bool state)
Definition: BaseType.cc:568
virtual BaseType * ptr_duplicate()=0
virtual void transfer_attributes(AttrTable *at)
Definition: BaseType.cc:644
virtual void dump(ostream &strm) const
dumps information about this object
Definition: BaseType.cc:291
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
Definition: BaseType.cc:1209
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
Definition: BaseType.cc:126
virtual Type type() const
Returns the type of the class instance.
Definition: BaseType.cc:365
Evaluate a constraint expression.
bool eval_selection(DDS &dds, const std::string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator and is called ...
virtual unsigned int width(bool constrained=false) const
Definition: Constructor.cc:249
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition: Constructor.cc:768
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Definition: Constructor.cc:194
Vars_iter get_vars_iter(int i)
Definition: Constructor.cc:388
virtual void add_var(BaseType *bt, Part part=nil)
Definition: Constructor.cc:407
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
Definition: Constructor.cc:550
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Constructor.cc:695
virtual BaseType * var(const string &name, bool exact_match=true, btp_stack *s=0)
btp_stack no longer needed; use back pointers (BaseType::get_parent())
Definition: Constructor.cc:267
virtual void transform_to_dap4(D4Group *root, Constructor *dest)
DAP2 to DAP4 transform.
Definition: Constructor.cc:141
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Definition: Constructor.cc:540
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net, then remove them from the object.
Definition: Constructor.cc:504
virtual void transfer_attributes(AttrTable *at)
Definition: Constructor.cc:844
virtual void intern_data()
Read data into this variable.
Definition: Constructor.cc:556
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Constructor.cc:913
Vars_iter var_end()
Definition: Constructor.cc:364
Vars_riter var_rbegin()
Definition: Constructor.cc:371
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Constructor.cc:650
virtual void set_send_p(bool state)
Definition: Constructor.cc:208
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: Constructor.cc:718
virtual void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
Definition: Constructor.cc:626
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
Definition: Constructor.cc:432
BaseType * get_var_index(int i)
Definition: Constructor.cc:397
virtual void set_in_selection(bool state)
Set the in_selection property.
Definition: Constructor.cc:834
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
Definition: Constructor.cc:476
Vars_iter var_begin()
Definition: Constructor.cc:356
Vars_riter var_rend()
Definition: Constructor.cc:379
virtual bool is_linear()
Check to see whether this variable can be printed simply.
Definition: Constructor.cc:823
virtual void del_var(const string &name)
Definition: Constructor.cc:448
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: Constructor.cc:218
virtual std::string FQN() const
Definition: Constructor.cc:181
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
Definition: Constructor.cc:792
void transform_to_dap4(AttrTable &at)
copy attributes from DAP2 to DAP4
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
Read data from the stream made by D4StreamMarshaller.
A class for software fault reporting.
Definition: InternalErr.h:65
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:50
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:55
Marshaller that knows how serialize dap data objects to a C++ iostream using XDR.
top level DAP object to house generic methods
Definition: AlarmHandler.h:36
Type
Identifies the data type.
Definition: Type.h:94
string www2id(const string &in, const string &escape, const string &except)
Definition: escaping.cc:220
string AttrType_to_String(const AttrType at)
Definition: AttrTable.cc:97
Part
Names the parts of multi-section constructor data types.
Definition: Type.h:48
string id2www(string in, const string &allowable)
Definition: escaping.cc:153