33#include "D4Sequence.h"
35#include "D4StreamMarshaller.h"
36#include "D4StreamUnMarshaller.h"
38#include "D4FilterClause.h"
43#include "InternalErr.h"
48#undef CLEAR_LOCAL_DATA
62void D4Sequence::m_duplicate(
const D4Sequence &s) {
63 d_length = s.d_length;
65 d_starting_row_number = s.d_starting_row_number;
66 d_ending_row_number = s.d_ending_row_number;
67 d_row_stride = s.d_row_stride;
70 for (D4SeqValues::const_iterator i = s.d_values.begin(), e = s.d_values.end(); i != e; ++i) {
73 for (D4SeqRow::const_iterator j = row.begin(), e = row.end(); j != e; ++j) {
75 dest->push_back((*j)->ptr_duplicate());
78 d_values.push_back(dest);
81 d_copy_clauses = s.d_copy_clauses;
82 d_clauses = (s.d_clauses != 0) ?
new D4FilterClauseList(*s.d_clauses) : 0;
96 : Constructor(n, dods_sequence_c, true ), d_clauses(0), d_copy_clauses(true), d_length(0) {}
109 : Constructor(n, d, dods_sequence_c, true ), d_clauses(0), d_copy_clauses(true), d_length(0) {}
116static inline void delete_bt(
BaseType *bt_ptr) {
delete bt_ptr; }
118static inline void delete_rows(
D4SeqRow *bt_row_ptr) {
119 for_each(bt_row_ptr->begin(), bt_row_ptr->end(), delete_bt);
124D4Sequence::~D4Sequence() {
130 if (!d_values.empty()) {
131 for_each(d_values.begin(), d_values.end(), delete_rows);
141 Constructor::operator=(rhs);
179 else if (filter && d_clauses && d_clauses->value()) {
184 else if (!filter || !d_clauses) {
192 }
while (!eof && !done);
221 DBG(cerr << __PRETTY_FUNCTION__ <<
" BEGIN" << endl);
229 DBG(cerr <<
"read_sequence_values() - Adding row" << endl);
231 for (Vars_iter i = d_vars.begin(), e = d_vars.end(); i != e; i++) {
232 if ((*i)->send_p()) {
233 DBG(cerr <<
":serialize() - reading data for " << (*i)->type_name() <<
" " << (*i)->name() << endl);
234 if ((*i)->type() == dods_sequence_c) {
235 DBG(cerr <<
"Reading child sequence values for " << (*i)->name() << endl);
238 d4s->d_copy_clauses =
false;
240 d4s->d_copy_clauses =
true;
241 row->back()->set_read_p(
true);
244 row->push_back((*i)->ptr_duplicate());
248 row->back()->set_read_p(
true);
254 d_values.push_back(row);
255 DBG(cerr <<
" read_sequence_values() - Row completed" << endl);
260 DBGN(cerr << __PRETTY_FUNCTION__ <<
" END added " << d_values.size() << endl);
283 DBGN(cerr << __PRETTY_FUNCTION__ <<
" BEGIN" << endl);
294 for (D4SeqValues::iterator i = d_values.begin(), e = d_values.end(); i != e; ++i) {
295 for (D4SeqRow::iterator j = (*i)->begin(), f = (*i)->end(); j != f; ++j) {
296 (*j)->serialize(m, dmr,
false);
300 DBGN(cerr << __PRETTY_FUNCTION__ <<
" END" << endl);
308 for (int64_t i = 0; i < d_length; ++i) {
310 for (Vars_iter i = d_vars.begin(), e = d_vars.end(); i != e; ++i) {
311 (*i)->deserialize(um, dmr);
312 row->push_back((*i)->ptr_duplicate());
314 d_values.push_back(row);
343virtual void set_row_number_constraint(
int start,
int stop,
int stride) {
345 throw Error(malformed_expr,
"Starting row number must precede the ending row number.");
347 d_starting_row_number = start;
348 d_row_stride = stride;
349 d_ending_row_number = stop;
358 if (row >= d_values.size())
360 return d_values[row];
373 auto elem = find_if(row->begin(), row->end(), [
name](
const BaseType *btp) { return btp->name() == name; });
375 return (elem != row->end()) ? *elem :
nullptr;
388 if (i >= row->size())
394void D4Sequence::print_one_row(ostream &out,
int row,
string space,
bool print_row_num) {
396 out <<
"\n" << space << row <<
": ";
411 while (j < elements && !bt_ptr) {
414 if (bt_ptr->
type() == dods_sequence_c)
415 static_cast<D4Sequence *
>(bt_ptr)->print_val_by_rows(out, space +
" ",
false, print_row_num);
422 while (j < elements) {
426 if (bt_ptr->
type() == dods_sequence_c)
427 static_cast<D4Sequence *
>(bt_ptr)->print_val_by_rows(out, space +
" ",
false, print_row_num);
436void D4Sequence::print_val_by_rows(ostream &out,
string space,
bool print_decl_p,
bool print_row_numbers) {
446 for (
int i = 0; i < rows; ++i) {
447 print_one_row(out, i, space, print_row_numbers);
450 print_one_row(out, rows, space, print_row_numbers);
462 print_val_by_rows(out, space, print_decl_p,
false);
474 strm << DapIndent::LMarg <<
"Sequence::dump - (" << (
void *)
this <<
")" << endl;
477 strm << DapIndent::LMarg <<
"# rows deserialized: " << d_length << endl;
478 strm << DapIndent::LMarg <<
"bracket notation information:" << endl;
482 strm << DapIndent::LMarg <<
"starting row #: " << d_starting_row_number << endl;
483 strm << DapIndent::LMarg <<
"row stride: " << d_row_stride << endl;
484 strm << DapIndent::LMarg <<
"ending row #: " << d_ending_row_number << endl;
486 DapIndent::UnIndent();
488 DapIndent::UnIndent();
The basic data type for the DODS DAP types.
virtual string type_name() const
Returns the type of the class instance as a string.
virtual string name() const
Returns the name of the class instance.
virtual bool read_p()
Has this variable been read?
virtual Type type() const
Returns the type of the class instance.
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
int element_count(bool leaves=false) override
Count the members of constructor types.
void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false) override
Print an ASCII representation of the variable structure.
void set_read_p(bool state) override
Set the 'read_p' property for the Constructor and its members.
bool read() override
Read the elements of Constructor marked for transmission.
void dump(ostream &strm) const override
dumps information about this object
List of DAP4 Filter Clauses.
virtual D4SeqRow * row_value(size_t row)
Get a whole row from the sequence.
virtual bool read_next_instance(bool filter)
Read the next instance of the sequence While the rest of the variables' read() methods are assumed to...
BaseType * ptr_duplicate() override
D4Sequence(const string &n)
The Sequence constructor.
int length() const override
The number of elements in a Sequence object.
D4FilterClauseList & clauses()
Access the filter clauses for this D4Sequence.
void set_length(int64_t count) override
bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool) override
Move data to the net, then remove them from the object.
bool deserialize(UnMarshaller &, DDS *, bool) override
Receive data from the net.
void dump(ostream &strm) const override
dumps information about this object
void print_val(ostream &out, string space="", bool print_decl_p=true) override
Prints the value of the variable.
void intern_data() override
Read data into this variable.
void read_sequence_values(bool filter)
Read a Sequence's value into memory.
virtual BaseType * var_value(size_t row, const string &name)
Get the BaseType pointer to the named variable of a given row.
void clear_local_data() override
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
virtual void put_count(int64_t count)
Read data from the stream made by D4StreamMarshaller.
A class for error processing.
top level DAP object to house generic methods
vector< BaseType * > D4SeqRow