57#include "ConstraintEvaluator.h"
59#include "D4Attributes.h"
62#include "XDRStreamMarshaller.h"
65#include "InternalErr.h"
80Structure::m_duplicate(
const Structure &s)
82 Constructor::m_duplicate(s);
86 DBG(cerr <<
"Copying structure: " <<
name() << endl);
88 for (Vars_iter i = cs.d_vars.begin(); i != cs.d_vars.end(); i++) {
89 DBG(cerr <<
"Copying field: " << (*i)->name() << endl);
95 BaseType *btp = (*i)->ptr_duplicate();
96 btp->set_parent(
this);
97 d_vars.push_back(btp);
129 DBG(cerr <<
"In Structure::copy_ctor for " <<
name() << endl);
133Structure::~Structure()
155 DBG(cerr << __func__ <<
"() - BEGIN" << endl;);
161 DBG(cerr << __func__ <<
"() - Calling Constructor::transform_to_dap4("<<
162 "'" << root->
name() <<
"':" << (
void*)root <<
","
163 "'" << dest->
name() <<
"':" << (
void*)dest <<
")"
167 DBG(cerr << __func__ <<
"() - Added new Structure '" << dest->name() <<
"' (" << (
void*)dest <<
168 ") to the container '" << container->
name() <<
"'" << endl;);
169 DBG(cerr << __func__ <<
"() - END"<< endl;);
182 DBG(cerr <<
" " << __func__ <<
" BEGIN" << endl);
195 dest->set_is_dap4(
false);
197 vector<BaseType *> dropped_vars;
199 vector<BaseType *> *new_vars = (*i)->transform_to_dap2(&dest->
get_attr_table() );
203 vector<BaseType*>::iterator vIter = new_vars->begin();
204 vector<BaseType*>::iterator end = new_vars->end();
206 for (vector<BaseType*>::iterator vi = new_vars->begin(), ve = new_vars->end(); vi != ve ; ++vi ) {
217 dropped_vars.push_back(*i);
221 AttrTable *dv_attr_table = make_dropped_vars_attr_table(&dropped_vars);
226 DBG(attrs->
print(cerr,
"",
true););
235 vector<BaseType *> *result =
new vector<BaseType *>();
236 result->push_back(dest);
238 DBG(cerr <<
" " << __func__ <<
" END" << endl);
248Structure::operator=(
const Structure &rhs)
252 Constructor::operator=(rhs);
260 for (Vars_iter i = d_vars.begin(); linear && i != d_vars.end(); i++) {
261 if ((*i)->type() == dods_structure_c)
264 linear = linear && (*i)->is_simple_type();
274 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
275 (*i)->set_send_p(state);
284 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
285 (*i)->set_read_p(state);
300 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
301 (*i)->set_in_selection(state);
312 if ((*i)->type() == dods_sequence_c)
314 else if ((*i)->type() == dods_structure_c)
330 throw InternalErr(__FILE__, __LINE__,
"The BaseType parameter cannot be null.");
332 if (bt->is_dap4_only_type())
333 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Structure.");
342 d_vars.push_back(btp);
353 throw InternalErr(__FILE__, __LINE__,
"The BaseType parameter cannot be null.");
355 if (bt->is_dap4_only_type())
356 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Structure.");
358 bt->set_parent(
this);
359 d_vars.push_back(bt);
369 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
370 if ((*i)->name() == n) {
388 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
404 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
423 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
426 sz += (*i)->width(constrained);
429 sz += (*i)->width(constrained);
441 DBG(cerr <<
"Structure::intern_data: " <<
name() << endl);
445 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
446 if ((*i)->send_p()) {
447 (*i)->intern_data(eval, dds);
454 Marshaller &m,
bool ce_eval)
456#if USE_LOCAL_TIMEOUT_SCHEME
463 if (ce_eval && !eval.eval_selection(dds,
dataset()))
466#if USE_LOCAL_TIMEOUT_SCHEME
469 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
470 if ((*i)->send_p()) {
472 XDRStreamMarshaller *sm =
dynamic_cast<XDRStreamMarshaller*
>(&m);
473 if (sm && sm->checksums() && (*i)->type() != dods_structure_c && (*i)->type() != dods_grid_c)
474 sm->reset_checksum();
476 (*i)->serialize(eval, dds, m,
false);
478 if (sm && sm->checksums() && (*i)->type() != dods_structure_c && (*i)->type() != dods_grid_c)
481 (*i)->serialize(eval, dds, m,
false);
492 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
493 (*i)->deserialize(um, dds, reuse);
532 return m_exact_match(n, s);
534 return m_leaf_match(n, s);
547 return m_leaf_match(
name, &s);
554Structure::m_leaf_match(
const string &name, btp_stack *s)
556 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
557 if ((*i)->name() ==
name) {
559 DBG(cerr <<
"Pushing " << this->
name() << endl);
560 s->push(
static_cast<BaseType *
>(
this));
564 if ((*i)->is_constructor_type()) {
568 DBG(cerr <<
"Pushing " << this->
name() << endl);
569 s->push(
static_cast<BaseType *
>(
this));
583Structure::m_exact_match(
const string &name, btp_stack *s)
586 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
587 if ((*i)->name() ==
name) {
589 s->push(
static_cast<BaseType *
>(
this));
597 string::size_type dot_pos =
name.find(
".");
598 if (dot_pos != string::npos) {
599 string aggregate =
name.substr(0, dot_pos);
600 string field =
name.substr(dot_pos + 1);
605 s->push(
static_cast<BaseType *
>(
this));
607 return agg_ptr->var(field,
true, s);
622 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
634 for (Vars_citer i = d_vars.begin(); i != d_vars.end();
635 i++, (
void)(i != d_vars.end() && out <<
", ")) {
636 (*i)->print_val(out,
"",
false);
659 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
661 if (!(*i)->check_semantics(msg,
true)) {
684 strm << DapIndent::LMarg <<
"Structure::dump - ("
685 << (
void *)
this <<
")" << endl ;
686 DapIndent::Indent() ;
688 DapIndent::UnIndent() ;
Contains the attributes for a dataset.
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual void set_name(const string &n)
Set the name of this attribute table.
virtual string get_name() const
Get the name of this attribute table.
virtual void print(FILE *out, string pad=" ", bool dereference=false)
Prints the attribute table.
virtual unsigned int get_size() const
Get the number of entries in this attribute table.
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 AttrTable & get_attr_table()
virtual string name() const
Returns the name of the class instance.
virtual void set_in_selection(bool state)
virtual bool read_p()
Has this variable been read?
virtual void set_read_p(bool state)
Sets the value of the read_p property.
virtual string dataset() const
Returns the name of the dataset used to create this instance.
virtual void set_attr_table(const AttrTable &at)
virtual void set_parent(BaseType *parent)
virtual D4Attributes * attributes()
virtual void set_send_p(bool state)
virtual BaseType * ptr_duplicate()=0
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
void transform_to_dap4(D4Group *root, Constructor *dest) override
DAP2 to DAP4 transform.
BaseType * var(const string &name, bool exact_match=true, btp_stack *s=nullptr) override
btp_stack no longer needed; use back pointers (BaseType::get_parent())
void add_var(BaseType *bt, Part part=nil) override
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.
unsigned int buf2val(void **) override
Reads the class data.
bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false) override
Receive data from the net.
void intern_data() override
Read data into this variable.
void set_read_p(bool state) override
Set the 'read_p' property for the Constructor and its members.
void print_val(FILE *out, string space="", bool print_decl_p=true) override
Prints the value of the variable.
void set_send_p(bool state) override
bool read() override
Read the elements of Constructor marked for transmission.
void set_in_selection(bool state) override
Set the in_selection property.
bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true) override
Move data to the net, then remove them from the object.
void add_var_nocopy(BaseType *bt, Part part=nil) override
unsigned int width(bool constrained=false) const override
bool check_semantics(string &msg, bool all=false) override
Compare an object's current state with the semantics of its type.
unsigned int val2buf(void *, bool) override
Loads class data.
virtual void del_var(const string &name)
Remove an element from a Constructor.
void dump(ostream &strm) const override
dumps information about this object
void transform_attrs_to_dap2(AttrTable *d2_attr_table)
Copy the attributes from this D4Attributes object to a DAP2 AttrTable.
A class for software fault reporting.
virtual void set_leaf_sequence(int lvl=1)
Mark the Sequence which holds the leaf elements.
Holds a structure (aggregate) type.
Structure(const string &n)
virtual void dump(ostream &strm) const
dumps information about this object
virtual void set_leaf_sequence(int level=1)
Traverse Structure, set Sequence leaf nodes.
virtual vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table)
DAP4 to DAP2 transform.
virtual bool is_linear()
Check to see whether this variable can be printed simply.
virtual BaseType * ptr_duplicate()
virtual void transform_to_dap4(D4Group *root, Constructor *container)
top level DAP object to house generic methods
string www2id(const string &in, const string &escape, const string &except)
Part
Names the parts of multi-section constructor data types.