libdap++  Updated for version 3.12.0
Sequence.cc
Go to the documentation of this file.
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2002,2003 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 // (c) COPYRIGHT URI/MIT 1994-1999
26 // Please read the full copyright statement in the file COPYRIGHT_URI.
27 //
28 // Authors:
29 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
30 
31 // Implementation for the class Structure
32 //
33 // jhrg 9/14/94
34 
35 
36 #include "config.h"
37 
38 #include <algorithm>
39 #include <string>
40 #include <sstream>
41 
42 //#define DODS_DEBUG
43 //#define DODS_DEBUG2
44 
45 #include "Byte.h"
46 #include "Int16.h"
47 #include "UInt16.h"
48 #include "Int32.h"
49 #include "UInt32.h"
50 #include "Float32.h"
51 #include "Float64.h"
52 #include "Str.h"
53 #include "Url.h"
54 #include "Array.h"
55 #include "Structure.h"
56 #include "Sequence.h"
57 #include "Grid.h"
58 
59 #include "Marshaller.h"
60 #include "UnMarshaller.h"
61 
62 #include "debug.h"
63 #include "Error.h"
64 #include "InternalErr.h"
65 #include "Sequence.h"
66 #include "DDS.h"
67 #include "DataDDS.h"
68 #include "util.h"
69 #include "InternalErr.h"
70 #include "escaping.h"
71 
72 using namespace std;
73 
74 namespace libdap {
75 
76 static const unsigned char end_of_sequence = 0xA5; // binary pattern 1010 0101
77 static const unsigned char start_of_instance = 0x5A; // binary pattern 0101 1010
78 
79 // Private member functions
80 
81 void
82 Sequence::m_duplicate(const Sequence &s)
83 {
84  d_row_number = s.d_row_number;
85  d_starting_row_number = s.d_starting_row_number;
86  d_ending_row_number = s.d_ending_row_number;
87  d_row_stride = s.d_row_stride;
88  d_leaf_sequence = s.d_leaf_sequence;
89  d_unsent_data = s.d_unsent_data;
90  d_wrote_soi = s.d_wrote_soi;
91  d_top_most = s.d_top_most;
92 
93  Sequence &cs = const_cast<Sequence &>(s);
94 
95  // Copy the template BaseType objects.
96  for (Vars_iter i = cs.var_begin(); i != cs.var_end(); i++) {
97  add_var((*i)) ;
98  }
99 
100  // Copy the BaseType objects used to hold values.
101  for (vector<BaseTypeRow *>::iterator rows_iter = cs.d_values.begin();
102  rows_iter != cs.d_values.end();
103  rows_iter++) {
104  // Get the current BaseType Row
105  BaseTypeRow *src_bt_row_ptr = *rows_iter;
106  // Create a new row.
107  BaseTypeRow *dest_bt_row_ptr = new BaseTypeRow;
108  // Copy the BaseType objects from a row to new BaseType objects.
109  // Push new BaseType objects onto new row.
110  for (BaseTypeRow::iterator bt_row_iter = src_bt_row_ptr->begin();
111  bt_row_iter != src_bt_row_ptr->end();
112  bt_row_iter++) {
113  BaseType *src_bt_ptr = *bt_row_iter;
114  BaseType *dest_bt_ptr = src_bt_ptr->ptr_duplicate();
115  dest_bt_row_ptr->push_back(dest_bt_ptr);
116  }
117  // Push new row onto d_values.
118  d_values.push_back(dest_bt_row_ptr);
119  }
120 }
121 
122 static void
123 write_end_of_sequence(Marshaller &m)
124 {
125  m.put_opaque( (char *)&end_of_sequence, 1 ) ;
126 }
127 
128 static void
129 write_start_of_instance(Marshaller &m)
130 {
131  m.put_opaque( (char *)&start_of_instance, 1 ) ;
132 }
133 
134 static unsigned char
135 read_marker(UnMarshaller &um)
136 {
137  unsigned char marker;
138  um.get_opaque( (char *)&marker, 1 ) ;
139 
140  return marker;
141 }
142 
143 static bool
144 is_start_of_instance(unsigned char marker)
145 {
146  return (marker == start_of_instance);
147 }
148 
149 static bool
150 is_end_of_sequence(unsigned char marker)
151 {
152  return (marker == end_of_sequence);
153 }
154 
155 // Public member functions
156 
165 Sequence::Sequence(const string &n) : Constructor(n, dods_sequence_c),
166  d_row_number(-1), d_starting_row_number(-1),
167  d_row_stride(1), d_ending_row_number(-1),
168  d_unsent_data(false), d_wrote_soi(false),
169  d_leaf_sequence(false), d_top_most(false)
170 {}
171 
182 Sequence::Sequence(const string &n, const string &d)
183  : Constructor(n, d, dods_sequence_c),
184  d_row_number(-1), d_starting_row_number(-1),
185  d_row_stride(1), d_ending_row_number(-1),
186  d_unsent_data(false), d_wrote_soi(false),
187  d_leaf_sequence(false), d_top_most(false)
188 {}
189 
192 {
193  m_duplicate(rhs);
194 }
195 
196 BaseType *
198 {
199  return new Sequence(*this);
200 }
201 
202 static inline void
203 delete_bt(BaseType *bt_ptr)
204 {
205  DBG2(cerr << "In delete_bt: " << bt_ptr << endl);
206  delete bt_ptr; bt_ptr = 0;
207 }
208 
209 static inline void
210 delete_rows(BaseTypeRow *bt_row_ptr)
211 {
212  DBG2(cerr << "In delete_rows: " << bt_row_ptr << endl);
213 
214  for_each(bt_row_ptr->begin(), bt_row_ptr->end(), delete_bt);
215 
216  delete bt_row_ptr; bt_row_ptr = 0;
217 }
218 
220 {
221  DBG2(cerr << "Entering Sequence::~Sequence" << endl);
222  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
223  BaseType *btp = *i ;
224  delete btp ; btp = 0;
225  }
226 
227  for_each(d_values.begin(), d_values.end(), delete_rows);
228  DBG2(cerr << "exiting Sequence::~Sequence" << endl);
229 }
230 
231 Sequence &
233 {
234  if (this == &rhs)
235  return *this;
236 
237  dynamic_cast<Constructor &>(*this) = rhs; // run Constructor=
238 
239  m_duplicate(rhs);
240 
241  return *this;
242 }
243 
247 bool
249 {
250  return true;
251 }
252 
253 string
255 {
256  ostringstream oss;
257 
258  oss << BaseType::toString();
259 
260  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
261  oss << (*i)->toString();
262  }
263 
264  oss << endl;
265 
266  return oss.str();
267 }
268 
269 #if 0
270 int
271 Sequence::element_count(bool leaves)
272 {
273  if (!leaves)
274  return d_vars.size();
275  else {
276  int i = 0;
277  for (Vars_iter iter = d_vars.begin(); iter != d_vars.end(); iter++) {
278  i += (*iter)->element_count(true);
279  }
280  return i;
281  }
282 }
283 #endif
284 
285 bool
287 {
288  bool linear = true;
289  bool seq_found = false;
290  for (Vars_iter iter = d_vars.begin(); linear && iter != d_vars.end(); iter++) {
291  if ((*iter)->type() == dods_sequence_c) {
292  // A linear sequence cannot have more than one child seq. at any
293  // one level. If we've already found a seq at this level, return
294  // false.
295  if (seq_found) {
296  linear = false;
297  break;
298  }
299  seq_found = true;
300  linear = static_cast<Sequence *>((*iter))->is_linear();
301  }
302  else if ((*iter)->type() == dods_structure_c) {
303  linear = static_cast<Structure*>((*iter))->is_linear();
304  }
305  else {
306  // A linear sequence cannot have Arrays, Lists or Grids.
307  linear = (*iter)->is_simple_type();
308  }
309  }
310 
311  return linear;
312 }
313 
314 #if 0
315 void
316 Sequence::set_send_p(bool state)
317 {
318  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
319  (*i)->set_send_p(state);
320  }
321 
322  BaseType::set_send_p(state);
323 }
324 
325 void
326 Sequence::set_read_p(bool state)
327 {
328  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
329  (*i)->set_read_p(state);
330  }
331 
332  BaseType::set_read_p(state);
333 }
334 #endif
335 #if 0
336 void
337 Sequence::set_in_selection(bool state)
338 {
339  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
340  (*i)->set_in_selection(state);
341  }
342 
344 }
345 #endif
346 #if 0
347 
356 void
357 Sequence::add_var(BaseType *bt, Part)
358 {
359  if (!bt)
360  throw InternalErr(__FILE__, __LINE__,
361  "Cannot add variable: NULL pointer");
362  if (bt->is_dap4_only_type())
363  throw InternalErr(__FILE__, __LINE__, "Attempt to add a DAP4 type to a DAP2 Sequence.");
364 
365  // Jose Garcia
366  // We append a copy of bt so the owner of bt is free to deallocate
367 
368  BaseType *bt_copy = bt->ptr_duplicate();
369  bt_copy->set_parent(this);
370  d_vars.push_back(bt_copy);
371 }
372 
384 void
385 Sequence::add_var_nocopy(BaseType *bt, Part)
386 {
387  if (!bt)
388  throw InternalErr(__FILE__, __LINE__,
389  "Cannot add variable: NULL pointer");
390  if (bt->is_dap4_only_type())
391  throw InternalErr(__FILE__, __LINE__, "Attempt to add a DAP4 type to a DAP2 Sequence.");
392 
393  bt->set_parent(this);
394  d_vars.push_back(bt);
395 }
396 #endif
397 #if 0
398 // Deprecated
399 BaseType *
400 Sequence::var(const string &n, btp_stack &s)
401 {
402  string name = www2id(n);
403 
404  BaseType *btp = m_exact_match(name, &s);
405  if (btp)
406  return btp;
407 
408  return m_leaf_match(name, &s);
409 }
410 
411 BaseType *
412 Sequence::var(const string &name, bool exact_match, btp_stack *s)
413 {
414  string n = www2id(name);
415 
416  if (exact_match)
417  return m_exact_match(n, s);
418  else
419  return m_leaf_match(n, s);
420 }
421 #endif
422 #if 0
423 BaseType *
424 Sequence::m_leaf_match(const string &name, btp_stack *s)
425 {
426  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
427  if ((*i)->name() == name) {
428  if (s)
429  s->push(static_cast<BaseType *>(this));
430  return *i;
431  }
432  if ((*i)->is_constructor_type()) {
433  BaseType *btp = (*i)->var(name, false, s);
434  if (btp) {
435  if (s)
436  s->push(static_cast<BaseType *>(this));
437  return btp;
438  }
439  }
440  }
441 
442  return 0;
443 }
444 
445 BaseType *
446 Sequence::m_exact_match(const string &name, btp_stack *s)
447 {
448  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
449  if ((*i)->name() == name) {
450  if (s)
451  s->push(static_cast<BaseType *>(this));
452  return *i;
453  }
454  }
455 
456  string::size_type dot_pos = name.find("."); // zero-based index of `.'
457  if (dot_pos != string::npos) {
458  string aggregate = name.substr(0, dot_pos);
459  string field = name.substr(dot_pos + 1);
460 
461  BaseType *agg_ptr = var(aggregate);
462  if (agg_ptr) {
463  if (s)
464  s->push(static_cast<BaseType *>(this));
465  return agg_ptr->var(field, true, s); // recurse
466  }
467  else
468  return 0; // qualified names must be *fully* qualified
469  }
470 
471  return 0;
472 }
473 #endif
474 
478 BaseTypeRow *
480 {
481  if (row >= d_values.size())
482  return 0;
483  return d_values[row];
484 }
485 
492 void
494 {
495  d_values = values;
496 }
497 
502 {
503  return d_values;
504 }
505 
511 BaseType *
512 Sequence::var_value(size_t row, const string &name)
513 {
514  BaseTypeRow *bt_row_ptr = row_value(row);
515  if (!bt_row_ptr)
516  return 0;
517 
518  BaseTypeRow::iterator bt_row_iter = bt_row_ptr->begin();
519  BaseTypeRow::iterator bt_row_end = bt_row_ptr->end();
520  while (bt_row_iter != bt_row_end && (*bt_row_iter)->name() != name)
521  ++bt_row_iter;
522 
523  if (bt_row_iter == bt_row_end)
524  return 0;
525  else
526  return *bt_row_iter;
527 }
528 
534 BaseType *
535 Sequence::var_value(size_t row, size_t i)
536 {
537  BaseTypeRow *bt_row_ptr = row_value(row);
538  if (!bt_row_ptr)
539  return 0;
540 
541  if (i >= bt_row_ptr->size())
542  return 0;
543 
544  return (*bt_row_ptr)[i];
545 }
546 
547 #if 0
548 unsigned int
550 {
551  unsigned int sz = 0;
552 
553  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
554  sz += (*i)->width();
555  }
556 
557  return sz;
558 }
559 
567 unsigned int
568 Sequence::width(bool constrained)
569 {
570  unsigned int sz = 0;
571 
572  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
573  if (constrained) {
574  if ((*i)->send_p())
575  sz += (*i)->width(constrained);
576  }
577  else {
578  sz += (*i)->width(constrained);
579  }
580  }
581 
582  return sz;
583 }
584 #endif
585 
586 // This version returns -1. Each API-specific subclass should define a more
587 // reasonable version. jhrg 5/24/96
588 
604 int
606 {
607  return -1;
608 }
609 
610 
611 int
613 {
614  return d_values.size();
615 }
616 
620 void
622 {
623  d_row_number = -1;
624 }
625 
626 // Notes:
627 // Assume that read() is implemented so that, when reading data for a nested
628 // sequence, only the outer most level is *actually* read.
629 // This is a consequence of our current (12/7/99) implementation of
630 // the JGOFS server (which is the only server to actually use nested
631 // sequences). 12/7/99 jhrg
632 //
633 // Stop assuming this. This logic is being moved into the JGOFS server
634 // itself. 6/1/2001 jhrg
635 
636 // The read() function returns a boolean value, with TRUE
637 // indicating that read() should be called again because there's
638 // more data to read, and FALSE indicating there's no more data
639 // to read. Note that this behavior is necessary to properly
640 // handle variables that contain Sequences. Jose Garcia If an
641 // error exists while reading, the implementers of the surrogate
642 // library SHOULD throw an Error object which will propagate
643 // beyond this point to to the original caller.
644 // Jose Garcia
645 
678 bool
679 Sequence::read_row(int row, DDS &dds,
680  ConstraintEvaluator &eval, bool ce_eval)
681 {
682  DBG2(cerr << "Entering Sequence::read_row for " << name() << endl);
683  if (row < d_row_number)
684  throw InternalErr("Trying to back up inside a sequence!");
685 
686  DBG2(cerr << "read_row: row number " << row
687  << ", current row " << d_row_number << endl);
688  if (row == d_row_number)
689  {
690  DBG2(cerr << "Leaving Sequence::read_row for " << name() << endl);
691  return true;
692  }
693 
694  dds.timeout_on();
695 
696  int eof = 0; // Start out assuming EOF is false.
697  while (!eof && d_row_number < row) {
698  if (!read_p()) {
699  eof = (read() == false);
700  }
701 
702  // Advance the row number if ce_eval is false (we're not supposed to
703  // evaluate the selection) or both ce_eval and the selection are
704  // true.
705  if (!eof && (!ce_eval || eval.eval_selection(dds, dataset())))
706  d_row_number++;
707 
708  set_read_p(false); // ...so that the next instance will be read
709  }
710 
711  // Once we finish the above loop, set read_p to true so that the caller
712  // knows that data *has* been read. This is how the read() methods of the
713  // elements of the sequence know to not call read() but instead look for
714  // data values inside themselves.
715  set_read_p(true);
716 
717  dds.timeout_off();
718 
719  // Return true if we have valid data, false if we've read to the EOF.
720  DBG2(cerr << "Leaving Sequence::read_row for " << name()
721  << " with " << (eof == 0) << endl);
722  return eof == 0;
723 }
724 
725 // Private. This is used to process constraints on the rows of a sequence.
726 // Starting with 3.2 we support constraints like Sequence[10:2:20]. This
727 // odd-looking logic first checks if d_ending_row_number is the sentinel
728 // value of -1. If so, the sequence was not constrained by row number and
729 // this method should never return true (which indicates that we're at the
730 // end of a row-number constraint). If d_ending_row_number is not -1, then is
731 // \e i at the end point? 6/1/2001 jhrg
732 inline bool
733 Sequence::is_end_of_rows(int i)
734 {
735  return ((d_ending_row_number == -1) ? false : (i > d_ending_row_number));
736 }
737 
798 bool
800  Marshaller &m, bool ce_eval)
801 {
802  DBG2(cerr << "Entering Sequence::serialize for " << name() << endl);
803 
804  // Special case leaf sequences!
805  if (is_leaf_sequence())
806  return serialize_leaf(dds, eval, m, ce_eval);
807  else
808  return serialize_parent_part_one(dds, eval, m);
809 }
810 
811 // We know this is not a leaf Sequence. That means that this Sequence holds
812 // another Sequence as one of its fields _and_ that child Sequence triggers
813 // the actual transmission of values.
814 
815 bool
818 {
819  DBG2(cerr << "Entering serialize_parent_part_one for " << name() << endl);
820 
821  int i = (d_starting_row_number != -1) ? d_starting_row_number : 0;
822 
823  // read_row returns true if valid data was read, false if the EOF was
824  // found. 6/1/2001 jhrg
825  // Since this is a parent sequence, read the row ignoring the CE (all of
826  // the CE clauses will be evaluated by the leaf sequence).
827  bool status = read_row(i, dds, eval, false);
828  DBG2(cerr << "Sequence::serialize_parent_part_one::read_row() status: " << status << endl);
829 
830  while (status && !is_end_of_rows(i)) {
831  i += d_row_stride;
832 
833  // DBG(cerr << "Writing Start of Instance marker" << endl);
834  // write_start_of_instance(sink);
835 
836  // In this loop serialize will signal an error with an exception.
837  for (Vars_iter iter = d_vars.begin(); iter != d_vars.end(); iter++) {
838  // Only call serialize for child Sequences; the leaf sequence
839  // will trigger the transmission of values for its parents (this
840  // sequence and maybe others) once it gets some valid data to
841  // send.
842  // Note that if the leaf sequence has no variables in the current
843  // projection, its serialize() method will never be called and that's
844  // the method that triggers actually sending values. Thus the leaf
845  // sequence must be the lowest level sequence with values whose send_p
846  // property is true.
847  if ((*iter)->send_p() && (*iter)->type() == dods_sequence_c)
848  (*iter)->serialize(eval, dds, m);
849  }
850 
851  set_read_p(false); // ...so this will read the next instance
852 
853  status = read_row(i, dds, eval, false);
854  DBG(cerr << "Sequence::serialize_parent_part_one::read_row() status: " << status << endl);
855  }
856  // Reset current row number for next nested sequence element.
857  d_row_number = -1;
858 
859  // Always write the EOS marker? 12/23/04 jhrg
860  // Yes. According to DAP2, a completely empty response is signaled by
861  // a return value of only the EOS marker for the outermost sequence.
862  if (d_top_most || d_wrote_soi) {
863  DBG(cerr << "Writing End of Sequence marker" << endl);
864  write_end_of_sequence(m);
865  d_wrote_soi = false;
866  }
867 
868  return true; // Signal errors with exceptions.
869 }
870 
871 // If we are here then we know that this is 'parent sequence' and that the
872 // leaf sequence has found valid data to send. We also know that
873 // serialize_parent_part_one has been called so data are in the instance's
874 // fields. This is where we send data. Whereas ..._part_one() contains a
875 // loop to iterate over all of rows in a parent sequence, this does not. This
876 // method assumes that the serialize_leaf() will call it each time it needs
877 // to be called.
878 //
879 // NB: This code only works if the child sequences appear after all other
880 // variables.
881 void
884 {
885  DBG(cerr << "Entering serialize_parent_part_two for " << name() << endl);
886 
887  BaseType *btp = get_parent();
888  if (btp && btp->type() == dods_sequence_c)
889  static_cast<Sequence&>(*btp).serialize_parent_part_two(dds, eval, m);
890 
891  if (d_unsent_data) {
892  DBG(cerr << "Writing Start of Instance marker" << endl);
893  d_wrote_soi = true;
894  write_start_of_instance(m);
895 
896  // In this loop serialize will signal an error with an exception.
897  for (Vars_iter iter = d_vars.begin(); iter != d_vars.end(); iter++) {
898  // Send all the non-sequence variables
899  DBG(cerr << "Sequence::serialize_parent_part_two(), serializing "
900  << (*iter)->name() << endl);
901  if ((*iter)->send_p() && (*iter)->type() != dods_sequence_c) {
902  DBG(cerr << "Send P is true, sending " << (*iter)->name() << endl);
903  (*iter)->serialize(eval, dds, m, false);
904  }
905  }
906 
907  d_unsent_data = false; // read should set this.
908  }
909 }
910 
911 // This code is only run by a leaf sequence. Note that a one level sequence
912 // is also a leaf sequence.
913 bool
915  ConstraintEvaluator &eval, Marshaller &m, bool ce_eval)
916 {
917  DBG(cerr << "Entering Sequence::serialize_leaf for " << name() << endl);
918  int i = (d_starting_row_number != -1) ? d_starting_row_number : 0;
919 
920  // read_row returns true if valid data was read, false if the EOF was
921  // found. 6/1/2001 jhrg
922  bool status = read_row(i, dds, eval, ce_eval);
923  DBG(cerr << "Sequence::serialize_leaf::read_row() status: " << status << endl);
924 
925  // Once the first valid (satisfies the CE) row of the leaf sequence has
926  // been read, we know we're going to send data. Send the current instance
927  // of the parent/ancestor sequences now, if there are any. We only need
928  // to do this once, hence it's not inside the while loop, but we only
929  // send the parent seq data _if_ there's data in the leaf to send, that's
930  // why we wait until after the first call to read_row() here in the leaf
931  // sequence.
932  //
933  // NB: It's important to only call serialize_parent_part_two() for a
934  // Sequence that really is the parent of a leaf sequence. The fancy cast
935  // will throw and exception if btp is not a Sequence, but doesn't test
936  // that it's a parent sequence as we've defined them here.
937  if (status && !is_end_of_rows(i)) {
938  BaseType *btp = get_parent();
939  if (btp && btp->type() == dods_sequence_c)
940  static_cast<Sequence&>(*btp).serialize_parent_part_two(dds,
941  eval, m);
942  }
943 
944  d_wrote_soi = false;
945  while (status && !is_end_of_rows(i)) {
946  i += d_row_stride;
947 
948  DBG(cerr << "Writing Start of Instance marker" << endl);
949  d_wrote_soi = true;
950  write_start_of_instance(m);
951 
952  // In this loop serialize will signal an error with an exception.
953  for (Vars_iter iter = d_vars.begin(); iter != d_vars.end(); iter++) {
954  DBG(cerr << "Sequence::serialize_leaf(), serializing "
955  << (*iter)->name() << endl);
956  if ((*iter)->send_p()) {
957  DBG(cerr << "Send P is true, sending " << (*iter)->name() << endl);
958  (*iter)->serialize(eval, dds, m, false);
959  }
960  }
961 
962  set_read_p(false); // ...so this will read the next instance
963 
964  status = read_row(i, dds, eval, ce_eval);
965  DBG(cerr << "Sequence::serialize_leaf::read_row() status: " << status << endl);
966  }
967 
968  // Only write the EOS marker if there's a matching Start Of Instance
969  // Marker in the stream.
970  if (d_wrote_soi || d_top_most) {
971  DBG(cerr << "Writing End of Sequence marker" << endl);
972  write_end_of_sequence(m);
973  }
974 
975  return true; // Signal errors with exceptions.
976 }
977 
1000 void
1002 {
1003  DBG(cerr << "Sequence::intern_data - for " << name() << endl);
1004  DBG2(cerr << " intern_data, values: " << &d_values << endl);
1005 
1006  // Why use a stack instead of return values? We need the stack because
1007  // Sequences neted three of more levels deep will loose the middle
1008  // instances when the intern_data_parent_part_two() code is run.
1009  sequence_values_stack_t sequence_values_stack;
1010 
1011  DBG2(cerr << " pushing d_values of " << name() << " (" << &d_values
1012  << ") on stack; size: " << sequence_values_stack.size() << endl);
1013  sequence_values_stack.push(&d_values);
1014 
1015  intern_data_private(eval, dds, sequence_values_stack);
1016 }
1017 
1018 void
1020  DDS &dds,
1021  sequence_values_stack_t &sequence_values_stack)
1022 {
1023  DBG(cerr << "Entering intern_data_private for " << name() << endl);
1024 
1025  if (is_leaf_sequence())
1026  intern_data_for_leaf(dds, eval, sequence_values_stack);
1027  else
1028  intern_data_parent_part_one(dds, eval, sequence_values_stack);
1029 }
1030 
1031 void
1033  ConstraintEvaluator & eval,
1035  sequence_values_stack)
1036 {
1037  DBG(cerr << "Entering intern_data_parent_part_one for " << name() << endl);
1038 
1039  int i = (get_starting_row_number() != -1) ? get_starting_row_number() : 0;
1040 
1041  // read_row returns true if valid data was read, false if the EOF was
1042  // found. 6/1/2001 jhrg
1043  // Since this is a parent sequence, read the row ignoring the CE (all of
1044  // the CE clauses will be evaluated by the leaf sequence).
1045  bool status = read_row(i, dds, eval, false);
1046 
1047  // Grab the current size of the value stack. We do this because it is
1048  // possible that no nested sequences for this row happened to be
1049  // selected because of a constraint evaluation or the last row is not
1050  // selected because of a constraint evaluation. In either case, no
1051  // nested sequence d_values are pushed onto the stack, so there is
1052  // nothing to pop at the end of this function. pcw 07/14/08
1053  SequenceValues::size_type orig_stack_size = sequence_values_stack.size() ;
1054 
1055  while (status
1056  && (get_ending_row_number() == -1
1057  || i <= get_ending_row_number()))
1058  {
1059  i += get_row_stride();
1060  for (Vars_iter iter = var_begin(); iter != var_end(); iter++) {
1061  if ((*iter)->send_p()) {
1062  switch ((*iter)->type()) {
1063  case dods_sequence_c:
1064  static_cast<Sequence&>(**iter).intern_data_private(
1065  eval, dds, sequence_values_stack);
1066  break;
1067 
1068  default:
1069  (*iter)->intern_data(eval, dds);
1070  break;
1071  }
1072  }
1073  }
1074 
1075  set_read_p(false); // ...so this will read the next instance
1076 
1077  status = read_row(i, dds, eval, false);
1078  }
1079 
1080  // Reset current row number for next nested sequence element.
1081  reset_row_number();
1082 
1083  // if the size of the stack is larger than the original size (retrieved
1084  // above) then pop the top set of d_values from the stack. If it's the
1085  // same, then no nested sequences, or possible the last nested sequence,
1086  // were pushed onto the stack, so there is nothing to pop.
1087  if( sequence_values_stack.size() > orig_stack_size )
1088  {
1089  DBG2(cerr << " popping d_values (" << sequence_values_stack.top()
1090  << ") off stack; size: " << sequence_values_stack.size() << endl);
1091  sequence_values_stack.pop();
1092  }
1093  DBG(cerr << "Leaving intern_data_parent_part_one for " << name() << endl);
1094 }
1095 
1096 void
1098  ConstraintEvaluator &eval,
1099  sequence_values_stack_t &sequence_values_stack)
1100 {
1101  DBG(cerr << "Entering intern_data_parent_part_two for " << name() << endl);
1102 
1103  BaseType *btp = get_parent();
1104  if (btp && btp->type() == dods_sequence_c) {
1105  static_cast<Sequence&>(*btp).intern_data_parent_part_two(
1106  dds, eval, sequence_values_stack);
1107  }
1108 
1109  DBG2(cerr << " stack size: " << sequence_values_stack.size() << endl);
1110  SequenceValues *values = sequence_values_stack.top();
1111  DBG2(cerr << " using values = " << (void *)values << endl);
1112 
1113  if (get_unsent_data()) {
1114  BaseTypeRow *row_data = new BaseTypeRow;
1115 
1116  // In this loop transfer_data will signal an error with an exception.
1117  for (Vars_iter iter = var_begin(); iter != var_end(); iter++) {
1118 
1119  if ((*iter)->send_p() && (*iter)->type() != dods_sequence_c) {
1120  row_data->push_back((*iter)->ptr_duplicate());
1121  }
1122  else if ((*iter)->send_p()) { //Sequence; must be the last variable
1123  Sequence *tmp = dynamic_cast<Sequence*>((*iter)->ptr_duplicate());
1124  if (!tmp) {
1125  delete row_data;
1126  throw InternalErr(__FILE__, __LINE__, "Expected a Sequence.");
1127  }
1128  row_data->push_back(tmp);
1129  DBG2(cerr << " pushing d_values of " << tmp->name()
1130  << " (" << &(tmp->d_values)
1131  << ") on stack; size: " << sequence_values_stack.size()
1132  << endl);
1133  // This pushes the d_values field of the newly created leaf
1134  // Sequence onto the stack. The code then returns to intern
1135  // _data_for_leaf() where this value will be used.
1136  sequence_values_stack.push(&(tmp->d_values));
1137  }
1138  }
1139 
1140  DBG2(cerr << " pushing values for " << name()
1141  << " to " << values << endl);
1142  values->push_back(row_data);
1143  set_unsent_data(false);
1144  }
1145  DBG(cerr << "Leaving intern_data_parent_part_two for " << name() << endl);
1146 }
1147 
1148 void
1150  ConstraintEvaluator &eval,
1151  sequence_values_stack_t &sequence_values_stack)
1152 {
1153  DBG(cerr << "Entering intern_data_for_leaf for " << name() << endl);
1154 
1155  int i = (get_starting_row_number() != -1) ? get_starting_row_number() : 0;
1156 
1157  DBG2(cerr << " reading row " << i << endl);
1158  bool status = read_row(i, dds, eval, true);
1159  DBG2(cerr << " status: " << status << endl);
1160  DBG2(cerr << " ending row number: " << get_ending_row_number() << endl);
1161 
1162  if (status && (get_ending_row_number() == -1 || i <= get_ending_row_number())) {
1163  BaseType *btp = get_parent();
1164  if (btp && btp->type() == dods_sequence_c) {
1165  // This call will read the values for the parent sequences and
1166  // then allocate a new instance for the leaf and push that onto
1167  // the stack.
1168  static_cast<Sequence&>(*btp).intern_data_parent_part_two(
1169  dds, eval, sequence_values_stack);
1170  }
1171 
1172  // intern_data_parent_part_two pushes the d_values field of the leaf
1173  // onto the stack, so this operation grabs that value and then loads
1174  // data into it.
1175  SequenceValues *values = sequence_values_stack.top();
1176  DBG2(cerr << " using values = " << values << endl);
1177 
1178  while (status && (get_ending_row_number() == -1
1179  || i <= get_ending_row_number())) {
1180  i += get_row_stride();
1181 
1182  // Copy data from the object's fields to this new BaeTypeRow instance
1183  BaseTypeRow *row_data = new BaseTypeRow;
1184  for (Vars_iter iter = var_begin(); iter != var_end(); iter++) {
1185  if ((*iter)->send_p()) {
1186  row_data->push_back((*iter)->ptr_duplicate());
1187  }
1188  }
1189 
1190  DBG2(cerr << " pushing values for " << name()
1191  << " to " << values << endl);
1192  // Save the row_data to values().
1193  values->push_back(row_data);
1194 
1195  set_read_p(false); // ...so this will read the next instance
1196  // Read the ith row into this object's fields
1197  status = read_row(i, dds, eval, true);
1198  }
1199 
1200  DBG2(cerr << " popping d_values (" << sequence_values_stack.top()
1201  << ") off stack; size: " << sequence_values_stack.size() << endl);
1202  sequence_values_stack.pop();
1203  }
1204  DBG(cerr << "Leaving intern_data_for_leaf for " << name() << endl);
1205 }
1206 
1227 bool
1229 {
1230  DataDDS *dd = dynamic_cast<DataDDS *>(dds);
1231  if (!dd)
1232  throw InternalErr("Expected argument 'dds' to be a DataDDS!");
1233 
1234  DBG2(cerr << "Reading from server/protocol version: "
1235  << dd->get_protocol_major() << "." << dd->get_protocol_minor()
1236  << endl);
1237 
1238  // Check for old servers.
1239  if (dd->get_protocol_major() < 2) {
1240  throw Error(string("The protocl version (") + dd->get_protocol()
1241  + ") indicates that this\nis an old server which may not correctly transmit Sequence variables.\nContact the server administrator.");
1242  }
1243 
1244  while (true) {
1245  // Grab the sequence stream's marker.
1246  unsigned char marker = read_marker(um);
1247  if (is_end_of_sequence(marker))
1248  break; // EXIT the while loop here!!!
1249  else if (is_start_of_instance(marker)) {
1250  d_row_number++;
1251  DBG2(cerr << "Reading row " << d_row_number << " of "
1252  << name() << endl);
1253  BaseTypeRow *bt_row_ptr = new BaseTypeRow;
1254  // Read the instance's values, building up the row
1255  for (Vars_iter iter = d_vars.begin(); iter != d_vars.end(); iter++) {
1256  BaseType *bt_ptr = (*iter)->ptr_duplicate();
1257  bt_ptr->deserialize(um, dds, reuse);
1258  DBG2(cerr << "Deserialized " << bt_ptr->name() << " ("
1259  << bt_ptr << ") = ");
1260  DBG2(bt_ptr->print_val(stderr, ""));
1261  bt_row_ptr->push_back(bt_ptr);
1262  }
1263  // Append this row to those accumulated.
1264  d_values.push_back(bt_row_ptr);
1265  }
1266  else
1267  throw Error("I could not read the expected Sequence data stream marker!");
1268  };
1269 
1270  return false;
1271 }
1272 
1273 // Return the current row number.
1274 
1286 int
1288 {
1289  return d_starting_row_number;
1290 }
1291 
1302 int
1304 {
1305  return d_row_stride;
1306 }
1307 
1319 int
1321 {
1322  return d_ending_row_number;
1323 }
1324 
1333 void
1334 Sequence::set_row_number_constraint(int start, int stop, int stride)
1335 {
1336  if (stop < start)
1337  throw Error(malformed_expr, "Starting row number must precede the ending row number.");
1338 
1339  d_starting_row_number = start;
1340  d_row_stride = stride;
1341  d_ending_row_number = stop;
1342 }
1343 
1344 #if 0
1345 
1347 unsigned int
1348 Sequence::val2buf(void *, bool)
1349 {
1350  throw InternalErr(__FILE__, __LINE__, "Never use this method; see the programmer's guide documentation.");
1351  return sizeof(Sequence);
1352 }
1353 
1358 unsigned int
1359 Sequence::buf2val(void **)
1360 {
1361  throw InternalErr(__FILE__, __LINE__, "Use Sequence::var_value() or Sequence::row_value() in place of Sequence::buf2val()");
1362  return sizeof(Sequence);
1363 }
1364 #endif
1365 
1366 void
1367 Sequence::print_one_row(FILE *out, int row, string space,
1368  bool print_row_num)
1369 {
1370  ostringstream oss;
1371  print_one_row(oss, row, space, print_row_num);
1372  fwrite(oss.str().data(), sizeof(char), oss.str().length(), out);
1373 }
1374 
1375 void
1376 Sequence::print_one_row(ostream &out, int row, string space,
1377  bool print_row_num)
1378 {
1379  if (print_row_num)
1380  out << "\n" << space << row << ": " ;
1381 
1382  out << "{ " ;
1383 
1384  int elements = element_count();
1385  int j = 0;
1386  BaseType *bt_ptr = 0;
1387 
1388  // This version of print_one_row() works for both data read with
1389  // deserialize(), where each variable is assumed to have valid data, and
1390  // intern_data(), where some/many variables do not. Because of that, it's
1391  // not correct to assume that all of the elements will be printed, which
1392  // is what the old code did.
1393  // Print the first value
1394  while (j < elements && !bt_ptr) {
1395  bt_ptr = var_value(row, j++);
1396  if (bt_ptr) { // data
1397  if (bt_ptr->type() == dods_sequence_c)
1398  static_cast<Sequence*>(bt_ptr)->print_val_by_rows
1399  (out, space + " ", false, print_row_num);
1400  else
1401  bt_ptr->print_val(out, space, false);
1402  }
1403  }
1404 
1405  // Print the remaining values
1406  while (j < elements) {
1407  bt_ptr = var_value(row, j++);
1408  if (bt_ptr) { // data
1409  out << ", ";
1410  if (bt_ptr->type() == dods_sequence_c)
1411  static_cast<Sequence*>(bt_ptr)->print_val_by_rows
1412  (out, space + " ", false, print_row_num);
1413  else
1414  bt_ptr->print_val(out, space, false);
1415  }
1416  }
1417 
1418  out << " }" ;
1419 }
1420 
1421 void
1422 Sequence::print_val_by_rows(FILE *out, string space, bool print_decl_p,
1423  bool print_row_numbers)
1424 {
1425  ostringstream oss;
1426  print_val_by_rows(oss, space, print_decl_p, print_row_numbers);
1427  fwrite(oss.str().data(), sizeof(char), oss.str().length(), out);
1428 }
1429 
1430 void
1431 Sequence::print_val_by_rows(ostream &out, string space, bool print_decl_p,
1432  bool print_row_numbers)
1433 {
1434  if (print_decl_p) {
1435  print_decl(out, space, false);
1436  out << " = " ;
1437  }
1438 
1439  out << "{ " ;
1440 
1441  int rows = number_of_rows() - 1;
1442  int i;
1443  for (i = 0; i < rows; ++i) {
1444  print_one_row(out, i, space, print_row_numbers);
1445  out << ", " ;
1446  }
1447  print_one_row(out, i, space, print_row_numbers);
1448 
1449  out << " }" ;
1450 
1451  if (print_decl_p)
1452  out << ";\n" ;
1453 }
1454 
1455 void
1456 Sequence::print_val(FILE *out, string space, bool print_decl_p)
1457 {
1458  print_val_by_rows(out, space, print_decl_p, false);
1459 }
1460 
1461 void
1462 Sequence::print_val(ostream &out, string space, bool print_decl_p)
1463 {
1464  print_val_by_rows(out, space, print_decl_p, false);
1465 }
1466 
1467 #if 0
1468 bool
1469 Sequence::check_semantics(string &msg, bool all)
1470 {
1471  if (!BaseType::check_semantics(msg))
1472  return false;
1473 
1474  if (!unique_names(d_vars, name(), type_name(), msg))
1475  return false;
1476 
1477  if (all)
1478  for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
1479  if (!(*i)->check_semantics(msg, true)) {
1480  return false;
1481  }
1482  }
1483 
1484  return true;
1485 }
1486 #endif
1487 
1488 void
1490 {
1491  d_leaf_sequence = state;
1492 }
1493 
1494 bool
1496 {
1497  return d_leaf_sequence;
1498 }
1499 
1524 void
1526 {
1527  bool has_child_sequence = false;
1528 
1529  if (lvl == 1) d_top_most = true;
1530 
1531  DBG2(cerr << "Processing sequence " << name() << endl);
1532 
1533  for (Vars_iter iter = d_vars.begin(); iter != d_vars.end(); iter++) {
1534  // About the test for send_p(): Only descend into a sequence if it has
1535  // fields that might be sent. Thus if, in a two-level sequence, nothing
1536  // in the lower level is to be sent, the upper level is marked as the
1537  // leaf sequence. This ensures that values _will_ be sent (see the comment
1538  // in serialize_leaf() and serialize_parent_part_one()).
1539  if ((*iter)->type() == dods_sequence_c && (*iter)->send_p()) {
1540  if (has_child_sequence)
1541  throw Error("This implementation does not support more than one nested sequence at a level. Contact the server administrator.");
1542 
1543  has_child_sequence = true;
1544  static_cast<Sequence&>(**iter).set_leaf_sequence(++lvl);
1545  }
1546  else if ((*iter)->type() == dods_structure_c) {
1547  static_cast<Structure&>(**iter).set_leaf_sequence(lvl);
1548  }
1549  }
1550 
1551  if (!has_child_sequence)
1552  set_leaf_p(true);
1553  else
1554  set_leaf_p(false);
1555 
1556  DBG2(cerr << "is_leaf_sequence(): " << is_leaf_sequence() << " (" << name() << ")" << endl);
1557 }
1558 
1567 void
1568 Sequence::dump(ostream &strm) const
1569 {
1570  strm << DapIndent::LMarg << "Sequence::dump - ("
1571  << (void *)this << ")" << endl ;
1572  DapIndent::Indent() ;
1573  Constructor::dump(strm) ;
1574  strm << DapIndent::LMarg << "# rows deserialized: " << d_row_number
1575  << endl ;
1576  strm << DapIndent::LMarg << "bracket notation information:" << endl ;
1577  DapIndent::Indent() ;
1578  strm << DapIndent::LMarg << "starting row #: " << d_starting_row_number
1579  << endl ;
1580  strm << DapIndent::LMarg << "row stride: " << d_row_stride << endl ;
1581  strm << DapIndent::LMarg << "ending row #: " << d_ending_row_number
1582  << endl ;
1584 
1585  strm << DapIndent::LMarg << "data been sent? " << d_unsent_data << endl ;
1586  strm << DapIndent::LMarg << "start of instance? " << d_wrote_soi << endl ;
1587  strm << DapIndent::LMarg << "is leaf sequence? " << d_leaf_sequence
1588  << endl ;
1589  strm << DapIndent::LMarg << "top most in hierarchy? " << d_top_most
1590  << endl ;
1592 }
1593 
1594 } // namespace libdap
1595 
virtual bool read_p()
Has this variable been read?
Definition: BaseType.cc:579
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Definition: Sequence.cc:1001
virtual void set_in_selection(bool state)
Set the in_selection property.
Definition: Constructor.cc:625
static void UnIndent()
Definition: DapIndent.cc:49
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Sequence.cc:1568
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:183
Part
Names the parts of multi-section constructor data types.
Definition: BaseType.h:95
void set_unsent_data(bool usd)
Set the unsent data property.
Definition: Sequence.h:305
#define malformed_expr
Definition: Error.h:64
std::vector< BaseType * > d_vars
Definition: Constructor.h:43
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)=0
Receive data from the net.
virtual bool read_row(int row, DDS &dds, ConstraintEvaluator &eval, bool ce_eval=true)
Definition: Sequence.cc:679
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Deserialize (read from the network) the entire Sequence.
Definition: Sequence.cc:1228
std::vector< BaseType * >::iterator Vars_iter
Definition: Constructor.h:56
virtual bool is_dap2_only_type()
Definition: Sequence.cc:248
virtual BaseType * get_parent()
Definition: BaseType.cc:788
vector< BaseTypeRow * > SequenceValues
Definition: Sequence.h:72
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
Definition: BaseType.cc:117
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Definition: Sequence.cc:799
int get_protocol_minor() const
Definition: DataDDS.h:137
virtual bool serialize_leaf(DDS &dds, ConstraintEvaluator &eval, Marshaller &m, bool ce_eval)
Definition: Sequence.cc:914
virtual void put_opaque(char *val, unsigned int len)=0
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
Definition: Constructor.cc:346
virtual BaseTypeRow * row_value(size_t row)
Get a whole row from the sequence.
Definition: Sequence.cc:479
virtual ~Sequence()
Definition: Sequence.cc:219
void timeout_off()
Definition: DDS.cc:862
virtual void set_row_number_constraint(int start, int stop, int stride=1)
Definition: Sequence.cc:1334
Holds a structure (aggregate) type.
Definition: Structure.h:85
virtual void add_var(BaseType *bt, Part part=nil)
Definition: Constructor.cc:321
Type type() const
Returns the type of the class instance.
Definition: BaseType.cc:282
virtual string toString()
Definition: BaseType.cc:205
#define DBG2(x)
Definition: debug.h:73
virtual void set_in_selection(bool state)
Definition: BaseType.cc:755
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Definition: Constructor.cc:110
virtual void print_val_by_rows(ostream &out, string space="", bool print_decl_p=true, bool print_row_numbers=true)
Definition: Sequence.cc:1431
virtual void set_leaf_sequence(int level=1)
Traverse Structure, set Sequence leaf nodes.
Definition: Structure.cc:224
A class for software fault reporting.
Definition: InternalErr.h:64
virtual void intern_data_private(ConstraintEvaluator &eval, DDS &dds, sequence_values_stack_t &sequence_values_stack)
Definition: Sequence.cc:1019
string dataset() const
Returns the name of the dataset used to create this instance.
Definition: BaseType.cc:275
bool eval_selection(DDS &dds, const string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called ...
virtual bool is_linear()
Check to see whether this variable can be printed simply.
Definition: Sequence.cc:286
virtual void intern_data_for_leaf(DDS &dds, ConstraintEvaluator &eval, sequence_values_stack_t &sequence_values_stack)
Definition: Sequence.cc:1149
#define DBG(x)
Definition: debug.h:58
string type_name() const
Returns the type of the class instance as a string.
Definition: BaseType.cc:296
bool get_unsent_data()
Get the unsent data property.
Definition: Sequence.h:299
virtual void set_send_p(bool state)
Definition: BaseType.cc:652
static void Indent()
Definition: DapIndent.cc:43
Sequence(const string &n)
The Sequence constructor.
Definition: Sequence.cc:165
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
Definition: Constructor.cc:389
virtual void set_leaf_sequence(int lvl=1)
Mark the Sequence which holds the leaf elements.
Definition: Sequence.cc:1525
Sequence & operator=(const Sequence &rhs)
Definition: Sequence.cc:232
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: BaseType.cc:618
Holds a sequence.
Definition: Sequence.h:172
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
Definition: Constructor.cc:583
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Constructor.cc:643
virtual int length()
Definition: Sequence.cc:605
virtual unsigned int val2buf(void *, bool)
Loads class data.
Definition: Constructor.h:99
vector< BaseType * > BaseTypeRow
Definition: Sequence.h:69
virtual void serialize_parent_part_two(DDS &dds, ConstraintEvaluator &eval, Marshaller &m)
Definition: Sequence.cc:882
virtual bool is_leaf_sequence()
Definition: Sequence.cc:1495
string name() const
Returns the name of the class instance.
Definition: BaseType.cc:254
virtual string toString()
Definition: Sequence.cc:254
BaseType * m_leaf_match(const string &name, btp_stack *s=0)
Definition: Constructor.cc:208
virtual BaseType * ptr_duplicate()=0
string www2id(const string &in, const string &escape, const string &except)
Definition: escaping.cc:218
void timeout_on()
Definition: DDS.cc:854
int get_starting_row_number()
Get the starting row number.
Definition: Sequence.cc:1287
virtual unsigned int width(bool constrained=false)
Definition: Constructor.cc:165
Evaluate a constraint expression.
virtual SequenceValues value()
Definition: Sequence.cc:501
virtual int number_of_rows()
Definition: Sequence.cc:612
void reset_row_number()
Rest the row number counter.
Definition: Sequence.cc:621
virtual unsigned int buf2val(void **)
Reads the class data.
Definition: Constructor.h:102
virtual void intern_data_parent_part_two(DDS &dds, ConstraintEvaluator &eval, sequence_values_stack_t &sequence_values_stack)
Definition: Sequence.cc:1097
static ostream & LMarg(ostream &strm)
Definition: DapIndent.cc:78
The basic data type for the DODS DAP types.
Definition: BaseType.h:199
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:53
virtual BaseType * var_value(size_t row, const string &name)
Get the BaseType pointer to the named variable of a given row.
Definition: Sequence.cc:512
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:470
virtual void print_one_row(ostream &out, int row, string space, bool print_row_num=false)
Definition: Sequence.cc:1376
Vars_iter var_begin()
Definition: Constructor.cc:270
virtual void intern_data_parent_part_one(DDS &dds, ConstraintEvaluator &eval, sequence_values_stack_t &sequence_values_stack)
Definition: Sequence.cc:1032
BaseType * m_exact_match(const string &name, btp_stack *s=0)
Definition: Constructor.cc:235
bool unique_names(vector< BaseType * > l, const string &var_name, const string &type_name, string &msg)
Definition: util.cc:338
Vars_iter var_end()
Definition: Constructor.cc:278
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Sequence.cc:1462
string get_protocol() const
Definition: DataDDS.h:129
virtual bool serialize_parent_part_one(DDS &dds, ConstraintEvaluator &eval, Marshaller &m)
Definition: Sequence.cc:816
virtual void set_leaf_p(bool state)
Definition: Sequence.cc:1489
stack< SequenceValues * > sequence_values_stack_t
Definition: Sequence.h:217
void m_duplicate(const Sequence &s)
Definition: Sequence.cc:82
A class for error processing.
Definition: Error.h:90
virtual int get_ending_row_number()
Get the ending row number.
Definition: Sequence.cc:1320
virtual void set_send_p(bool state)
Definition: Constructor.cc:124
virtual BaseType * ptr_duplicate()
Definition: Sequence.cc:197
Holds a DAP2 DDS.
Definition: DataDDS.h:77
virtual int get_row_stride()
Get the row stride.
Definition: Sequence.cc:1303
int get_protocol_major() const
Definition: DataDDS.h:133
virtual void set_value(SequenceValues &values)
Definition: Sequence.cc:493
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: Constructor.cc:134
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)=0
Prints the value of the variable.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
Definition: BaseType.cc:1153