71 DBG(cerr <<
"In Constructor::m_duplicate for " << c.
name() << endl);
77 while (i != c.
d_vars.end()) {
78 BaseType *btp = (*i++)->ptr_duplicate();
80 d_vars.push_back(btp);
83 DBG(cerr <<
"Exiting Constructor::m_duplicate for " << c.
name() << endl);
88 Constructor::Constructor(
const string &name,
const Type &type,
bool is_dap4)
102 Constructor::Constructor(
const string &name,
const string &dataset,
const Type &type,
bool is_dap4)
103 :
BaseType(name, dataset, type, is_dap4)
108 DBG(cerr <<
"In Constructor::copy_ctor for " << rhs.
name() << endl);
115 while (i !=
d_vars.end()) {
123 DBG(cerr <<
"Entering Constructor::operator=" << endl);
127 dynamic_cast<BaseType &
>(*this) = rhs;
131 DBG(cerr <<
"Exiting Constructor::operator=" << endl);
176 i += (*j)->element_count(leaves);
186 (*i)->set_send_p(state);
196 (*i)->set_read_p(state);
231 sz += (*i)->width(constrained);
234 sz += (*i)->width(constrained);
272 if ((*i)->name() ==
name) {
274 DBG(cerr <<
"Pushing " << this->
name() << endl);
275 s->push(static_cast<BaseType *>(
this));
279 if ((*i)->is_constructor_type()) {
283 DBG(cerr <<
"Pushing " << this->
name() << endl);
284 s->push(static_cast<BaseType *>(
this));
300 if ((*i)->name() ==
name) {
302 s->push(static_cast<BaseType *>(
this));
310 string::size_type dot_pos = name.find(
".");
311 if (dot_pos != string::npos) {
312 string aggregate = name.substr(0, dot_pos);
313 string field = name.substr(dot_pos + 1);
318 s->push(static_cast<BaseType *>(
this));
320 return agg_ptr->
var(field,
true, s);
365 return d_vars.begin() + i;
374 return *(
d_vars.begin() + i);
387 throw InternalErr(__FILE__, __LINE__,
"The BaseType parameter cannot be null.");
389 if (bt->is_dap4_only_type())
390 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Structure.");
410 throw InternalErr(__FILE__, __LINE__,
"The BaseType parameter cannot be null.");
412 if (bt->is_dap4_only_type())
413 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Structure.");
427 if ((*i)->name() == n) {
453 DBG(cerr <<
"Entering Constructor::read..." << endl);
467 DBG(cerr <<
"Constructor::intern_data: " <<
name() << endl);
472 if ((*i)->send_p()) {
473 (*i)->intern_data(eval, dds);
492 if ((*i)->send_p()) {
496 sm->reset_checksum();
498 (*i)->serialize(eval, dds, m,
false);
505 (*i)->serialize(eval, dds, m,
true);
517 (*i)->deserialize(um, dds, reuse);
526 throw InternalErr(__FILE__, __LINE__,
"Computing a checksum alone is not supported for Constructor types.");
533 if ((*i)->send_p()) {
534 (*i)->intern_data(checksum);
571 if (filter && !eval.eval_selection(dmr,
dataset()))
576 if ((*i)->send_p()) {
577 (*i)->serialize(m, dmr, filter);
586 (*i)->deserialize(um, dmr);
592 bool constraint_info,
bool constrained)
595 print_decl(oss, space, print_semi, constraint_info, constrained);
596 fwrite(oss.str().data(),
sizeof(char), oss.str().length(), out);
601 bool constraint_info,
bool constrained)
603 if (constrained && !
send_p())
608 (*i)->print_decl(out, space +
" ",
true, constraint_info, constrained);
612 if (constraint_info) {
614 out <<
": Send True";
616 out <<
": Send False";
628 fwrite(oss.str().data(),
sizeof(char), oss.str().length(), out);
641 i++, (void)(i !=
d_vars.end() && out <<
", ")) {
642 (*i)->print_val(out,
"",
false);
673 class PrintFieldXMLWriter :
public unary_function<BaseType *, void>
678 PrintFieldXMLWriter(
XMLWriter &x,
bool c)
679 : d_xml(x), d_constrained(c)
682 void operator()(BaseType *btp)
684 btp->print_xml_writer(d_xml, d_constrained);
691 if (constrained && !
send_p())
698 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
699 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
720 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
724 class PrintDAP4FieldXMLWriter :
public unary_function<BaseType *, void>
729 PrintDAP4FieldXMLWriter(
XMLWriter &x,
bool c) : d_xml(x), d_constrained(c) {}
731 void operator()(BaseType *btp)
733 btp->print_dap4(d_xml, d_constrained);
741 if (constrained && !
send_p())
748 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
749 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
753 for_each(
var_begin(),
var_end(), PrintDAP4FieldXMLWriter(xml, constrained));
757 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
773 if (!(*i)->check_semantics(msg,
true)) {
808 (*i)->set_in_selection(state);
826 << (
void *)
this <<
")" << endl ;
833 for (; i != ie; i++) {
void set_is_dap4(const bool v)
virtual bool read_p()
Has this variable been read?
virtual void set_in_selection(bool state)
Set the in_selection property.
abstract base class used to unmarshall/deserialize dap data objects
xmlTextWriterPtr get_writer()
void m_duplicate(const Constructor &s)
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())
Part
Names the parts of multi-section constructor data types.
std::vector< BaseType * >::reverse_iterator Vars_riter
std::vector< BaseType * > d_vars
virtual unsigned int width(bool constrained=false) const
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Read data from the stream made by D4StreamMarshaller.
std::vector< BaseType * >::iterator Vars_iter
virtual std::string FQN() const
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response...
BaseType * transform_to_dap4(D4Group *root, Constructor *dest)
DAP2 to DAP4 transform.
void print_xml_writer(XMLWriter &xml)
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
virtual void add_var(BaseType *bt, Part part=nil)
Type
Identifies the data type.
Type type() const
Returns the type of the class instance.
Constructor & operator=(const Constructor &rhs)
virtual void set_in_selection(bool state)
virtual int element_count(bool leaves=false)
Count the members of constructor types.
stack< BaseType * > btp_stack
virtual void set_parent(BaseType *parent)
A class for software fault reporting.
string dataset() const
Returns the name of the dataset used to create this instance.
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Returns a pointer to a member of a constructor class.
string type_name() const
Returns the type of the class instance as a string.
virtual bool is_linear()
Check to see whether this variable can be printed simply.
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
virtual void set_send_p(bool state)
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net.
virtual BaseType * get_parent() const
virtual void dump(ostream &strm) const
dumps information about this object
BaseType * get_var_index(int i)
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
virtual void set_read_p(bool state)
Sets the value of the read_p property.
virtual D4Attributes * attributes()
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
virtual void dump(ostream &strm) const
dumps information about this object
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
virtual std::string FQN() const
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
string name() const
Returns the name of the class instance.
BaseType * m_leaf_match(const string &name, btp_stack *s=0)
std::vector< BaseType * >::const_iterator Vars_citer
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
virtual BaseType * ptr_duplicate()=0
string www2id(const string &in, const string &escape, const string &except)
Evaluate a constraint expression.
static ostream & LMarg(ostream &strm)
virtual AttrTable & get_attr_table()
The basic data type for the DODS DAP types.
abstract base class used to marshal/serialize dap data objects
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.
BaseType * m_exact_match(const string &name, btp_stack *s=0)
bool unique_names(vector< BaseType * > l, const string &var_name, const string &type_name, string &msg)
bool eval_selection(DDS &dds, const std::string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called ...
Vars_iter get_vars_iter(int i)
void print_dap4(XMLWriter &xml, bool constrained=false)
virtual void del_var(const string &name)
virtual void set_send_p(bool state)
void transform_to_dap4(AttrTable &at)
copy attributes from DAP2 to DAP4
marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using XDR ...
virtual bool send_p()
Should this variable be sent?
string id2www(string in, const string &allowable)
void print_dap4(XMLWriter &xml) const
unsigned int get_doc_size()
virtual void set_read_p(bool state)
Sets the value of the read_p property.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
virtual BaseType * transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.