45 #include <ConstraintEvaluator.h>
46 #include <Marshaller.h>
47 #include <UnMarshaller.h>
50 #include "BESIndent.h"
51 #include "TabularSequence.h"
61 static const unsigned char end_of_sequence = 0xA5;
62 static const unsigned char start_of_instance = 0x5A;
65 write_end_of_sequence(Marshaller &m)
67 m.put_opaque( (
char *)&end_of_sequence, 1 ) ;
71 write_start_of_instance(Marshaller &m)
73 m.put_opaque( (
char *)&start_of_instance, 1 ) ;
76 void 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.");
142 TabularSequence::serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m,
bool ce_eval )
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);
195 void TabularSequence::intern_data(ConstraintEvaluator &eval, DDS &dds)
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);
251 TabularSequence::dump(ostream &strm)
const
253 strm << BESIndent::LMarg <<
"TabularSequence::dump - (" << (
void *)
this <<
")" << endl ;
254 BESIndent::Indent() ;
255 Sequence::dump(strm) ;
256 BESIndent::UnIndent() ;