33#include <libdap/BaseType.h>
34#include <libdap/Byte.h>
35#include <libdap/Int16.h>
36#include <libdap/Int32.h>
37#include <libdap/UInt16.h>
38#include <libdap/UInt32.h>
39#include <libdap/Float32.h>
40#include <libdap/Float64.h>
41#include <libdap/Str.h>
42#include <libdap/Url.h>
44#include <libdap/DDS.h>
45#include <libdap/ConstraintEvaluator.h>
46#include <libdap/Marshaller.h>
47#include <libdap/UnMarshaller.h>
48#include <libdap/debug.h>
51#include "TabularSequence.h"
61static const unsigned char end_of_sequence = 0xA5;
62static const unsigned char start_of_instance = 0x5A;
65write_end_of_sequence(Marshaller &m)
67 m.put_opaque( (
char *)&end_of_sequence, 1 ) ;
71write_start_of_instance(Marshaller &m)
73 m.put_opaque( (
char *)&start_of_instance, 1 ) ;
76void TabularSequence::load_prototypes_with_values(BaseTypeRow &btr,
bool safe)
82 Vars_iter i = d_vars.begin(), e = d_vars.end();
83 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
85 if (safe && (i == e || ((*i)->type() != (*vi)->var()->type())))
86 throw InternalErr(__FILE__, __LINE__,
"Expected number and types to match when loading values for selection expression evaluation.");
89 switch ((*i)->type()) {
91 static_cast<Byte*
>(*i++)->set_value(
static_cast<Byte*
>(*vi)->value());
94 static_cast<Int16*
>(*i++)->set_value(
static_cast<Int16*
>((*vi))->value());
97 static_cast<Int32*
>(*i++)->set_value(
static_cast<Int32*
>((*vi))->value());
100 static_cast<UInt16*
>(*i++)->set_value(
static_cast<UInt16*
>((*vi))->value());
103 static_cast<UInt32*
>(*i++)->set_value(
static_cast<UInt32*
>((*vi))->value());
106 static_cast<Float32*
>(*i++)->set_value(
static_cast<Float32*
>((*vi))->value());
109 static_cast<Float64*
>(*i++)->set_value(
static_cast<Float64*
>((*vi))->value());
112 static_cast<Str*
>(*i++)->set_value(
static_cast<Str*
>((*vi))->value());
115 static_cast<Url*
>(*i++)->set_value(
static_cast<Url*
>((*vi))->value());
118 throw InternalErr(__FILE__, __LINE__,
"Expected a scalar type when loading values for selection expression evaluation.");
144 DBG(cerr <<
"Entering TabularSequence::serialize for " << name() << endl);
146 SequenceValues &values = value_ref();
149 for (SequenceValues::iterator i = values.begin(), e = values.end(); i != e; ++i) {
151 BaseTypeRow &btr = **i;
156 load_prototypes_with_values(btr,
false);
159 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
161 (*vi)->buf2val(&val);
162 d_vars.at(j++)->val2buf(val);
165 DBG(cerr << __func__ <<
": Sequence element: " << hex << *btr.begin() << dec << endl);
167 if (ce_eval && !eval.eval_selection(dds, dataset()))
171 write_start_of_instance(m);
174 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
175 if ((*vi)->send_p()) {
176 (*vi)->serialize(eval, dds, m,
false);
181 write_end_of_sequence(m);
197 DBG(cerr <<
"Entering TabularSequence::intern_data" << endl);
204 SequenceValues result;
205 SequenceValues &values = value_ref();
207 for (SequenceValues::iterator i = values.begin(), e = values.end(); i != e; ++i) {
209 BaseTypeRow &btr = **i;
213 load_prototypes_with_values(btr,
false );
216 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
219 (*vi)->buf2val(&val);
220 d_vars.at(j++)->val2buf(val);
224 if (!eval.eval_selection(dds, dataset()))
227 BaseTypeRow *result_row =
new BaseTypeRow();
228 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
229 if ((*vi)->send_p()) {
230 result_row->push_back(*vi);
234 result.push_back(result_row);
239 DBG(cerr <<
"Leaving TabularSequence::intern_data" << endl);
253 strm << BESIndent::LMarg <<
"TabularSequence::dump - (" << (
void *)
this <<
")" << endl ;
254 BESIndent::Indent() ;
255 Sequence::dump(strm) ;
256 BESIndent::UnIndent() ;
virtual void dump(ostream &strm) const
dumps information about this object
virtual void intern_data(libdap::ConstraintEvaluator &eval, libdap::DDS &dds)
virtual bool serialize(libdap::ConstraintEvaluator &eval, libdap::DDS &dds, libdap::Marshaller &m, bool ce_eval=true)