63 static const unsigned char end_of_sequence = 0xA5;
64 static const unsigned char start_of_instance = 0x5A;
67 write_end_of_sequence(Marshaller &m)
69 m.put_opaque( (
char *)&end_of_sequence, 1 );
73 write_start_of_instance(Marshaller &m)
75 m.put_opaque( (
char *)&start_of_instance, 1 );
79 read_marker(UnMarshaller &um)
82 um.get_opaque( (
char *)&marker, 1 );
88 is_start_of_instance(
unsigned char marker)
90 return (marker == start_of_instance);
94 is_end_of_sequence(
unsigned char marker)
96 return (marker == end_of_sequence);
112 d_starting_row_number = s.d_starting_row_number;
113 d_ending_row_number = s.d_ending_row_number;
114 d_row_stride = s.d_row_stride;
117 for (D4SeqValues::const_iterator i = s.
d_values.begin(), e = s.
d_values.end(); i != e; ++i) {
120 for (D4SeqRow::const_iterator j = row.begin(), e = row.end(); j != e; ++j) {
122 dest->push_back((*j)->ptr_duplicate());
125 d_values.push_back(dest);
139 D4Sequence::D4Sequence(
const string &n) :
172 static inline void delete_bt(
BaseType *bt_ptr)
177 static inline void delete_rows(
D4SeqRow *bt_row_ptr)
179 for_each(bt_row_ptr->begin(), bt_row_ptr->end(), delete_bt);
192 if (
this == &rhs)
return *
this;
236 if (!eof && (!filter )) {
240 }
while (!eof && !done);
242 DBG(cerr <<
"D4Sequence::read_next_instance eof: " << eof << endl);
263 if ((*i)->send_p()) {
264 (*i)->compute_checksum(checksum);
277 if ((*i)->send_p()) {
279 row->push_back((*i)->ptr_duplicate());
283 row->back()->set_read_p(
true);
287 if (!row->back()->is_constructor_type()) row->back()->compute_checksum(checksum);
319 if ((*i)->send_p()) {
321 row->push_back((*i)->ptr_duplicate());
325 row->back()->set_read_p(
true);
329 DBG(cerr <<
"D4Sequence::serialize Added row" << endl);
334 DBG(cerr <<
"D4Sequence::serialize count: " <<
d_length << endl);
338 for (D4SeqValues::iterator i =
d_values.begin(), e =
d_values.end(); i != e; ++i) {
339 for (D4SeqRow::iterator j = (*i)->begin(), f = (*i)->end(); j != f; ++j) {
340 (*j)->serialize(m, dmr,
false);
348 DBG(cerr <<
"D4Sequence::deserialize count: " <<
d_length << endl);
350 for (int64_t i = 0; i <
d_length; ++i) {
353 (*i)->deserialize(um, dmr);
354 row->push_back((*i)->ptr_duplicate());
369 virtual void set_row_number_constraint(
int start,
int stop,
int stride)
374 d_starting_row_number = start;
375 d_row_stride = stride;
376 d_ending_row_number = stop;
387 if (row >=
d_values.size())
return 0;
391 static bool base_type_name_eq(
BaseType *btp,
const string name)
393 return btp->
name() == name;
407 D4SeqRow::iterator elem = find_if(row->begin(), row->end(), bind2nd(ptr_fun(base_type_name_eq), name));
408 return (elem != row->end()) ? *elem : 0;
422 if (i >= row->size())
return 0;
429 if (print_row_num) out <<
"\n" << space << row <<
": ";
444 while (j < elements && !bt_ptr) {
447 if (bt_ptr->
type() ==
dods_sequence_c) static_cast<D4Sequence*>(bt_ptr)->print_val_by_rows(out,
448 space +
" ",
false, print_row_num);
455 while (j < elements) {
459 if (bt_ptr->
type() ==
dods_sequence_c) static_cast<D4Sequence*>(bt_ptr)->print_val_by_rows(out,
460 space +
" ",
false, print_row_num);
480 for (
int i = 0; i < rows; ++i) {
489 if (print_decl_p) out <<
";\n";
507 strm <<
DapIndent::LMarg <<
"Sequence::dump - (" << (
void *)
this <<
")" << endl;
515 strm <<
DapIndent::LMarg <<
"starting row #: " << d_starting_row_number << endl;
517 strm <<
DapIndent::LMarg <<
"ending row #: " << d_ending_row_number << endl;
virtual void print_one_row(ostream &out, int row, string space, bool print_row_num=false)
virtual BaseType * ptr_duplicate()
virtual void put_count(int64_t count)
std::vector< BaseType * > d_vars
D4Sequence(const string &n)
The Sequence constructor.
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...
Read data from the stream made by D4StreamMarshaller.
std::vector< BaseType * >::iterator Vars_iter
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response...
virtual BaseType * var_value(size_t row, const string &name)
Get the BaseType pointer to the named variable of a given row.
Type type() const
Returns the type of the class instance.
vector< BaseType * > D4SeqRow
virtual int element_count(bool leaves=false)
Count the members of constructor types.
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
virtual void set_length(int count)
virtual void dump(ostream &strm) const
dumps information about this object
virtual int length() const
The number of elements in a Sequence object.
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
virtual void dump(ostream &strm) const
dumps information about this object
D4Sequence & operator=(const D4Sequence &rhs)
string name() const
Returns the name of the class instance.
virtual void intern_data(ConstraintEvaluator &, DDS &)
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Evaluate a constraint expression.
static ostream & LMarg(ostream &strm)
virtual bool deserialize(UnMarshaller &, DDS *, bool)
Receive data from the net.
The basic data type for the DODS DAP types.
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.
virtual D4SeqRow * row_value(size_t row)
Get a whole row from the sequence.
A class for error processing.
virtual void print_val_by_rows(ostream &out, string space="", bool print_decl_p=true, bool print_row_numbers=true)
virtual bool serialize(ConstraintEvaluator &, DDS &, Marshaller &, bool)
Move data to the net.
void m_duplicate(const D4Sequence &s)