52 #include "Structure.h" 57 #include "ConstraintEvaluator.h" 59 #include "D4Attributes.h" 62 #include "XDRStreamMarshaller.h" 65 #include "InternalErr.h" 79 Structure::m_duplicate(
const Structure &s)
81 Constructor::m_duplicate(s);
85 DBG(cerr <<
"Copying structure: " <<
name() << endl);
87 for (Vars_iter i = cs.d_vars.begin(); i != cs.d_vars.end(); i++) {
88 DBG(cerr <<
"Copying field: " << (*i)->name() << endl);
94 BaseType *btp = (*i)->ptr_duplicate();
95 btp->set_parent(
this);
96 d_vars.push_back(btp);
128 DBG(cerr <<
"In Structure::copy_ctor for " <<
name() << endl);
132 Structure::~Structure()
154 DBG(cerr << __func__ <<
"() - BEGIN" << endl;);
160 DBG(cerr << __func__ <<
"() - Calling Constructor::transform_to_dap4("<<
161 "'" << root->
name() <<
"':" << (
void*)root <<
"," 162 "'" << dest->
name() <<
"':" << (
void*)dest <<
")" 166 DBG(cerr << __func__ <<
"() - Added new Structure '" << dest->name() <<
"' (" << (
void*)dest <<
167 ") to the container '" << container->
name() <<
"'" << endl;);
168 DBG(cerr << __func__ <<
"() - END"<< endl;);
181 DBG(cerr <<
" " << __func__ <<
" BEGIN" << endl);
186 dest->set_is_dap4(
false);
188 vector<BaseType *> dropped_vars;
190 vector<BaseType *> *new_vars = (*i)->transform_to_dap2(attrs);
193 vector<BaseType*>::iterator vIter = new_vars->begin();
194 vector<BaseType*>::iterator end = new_vars->end();
195 for( ; vIter!=end ; vIter++ ){
206 dropped_vars.push_back(*i);
210 AttrTable *dv_attr_table = make_dropped_vars_attr_table(&dropped_vars);
212 DBG(cerr <<
" " << __func__ <<
"() - Adding "<< dv_attr_table->
get_name() <<
" AttrTable" << endl);
215 DBG(attrs->
print(cerr,
"",
true););
220 vector<BaseType *> *result =
new vector<BaseType *>();
221 result->push_back(dest);
222 DBG(cerr <<
" " << __func__ <<
" END" << endl);
231 Structure::operator=(
const Structure &rhs)
233 DBG(cerr <<
"Entering Structure::operator=" << endl);
241 DBG(cerr <<
"Exiting Structure::operator=" << endl);
250 return d_vars.size();
253 for (Vars_iter j = d_vars.begin(); j != d_vars.end(); j++) {
254 i += (*j)->element_count(leaves);
265 for (Vars_iter i = d_vars.begin(); linear && i != d_vars.end(); i++) {
266 if ((*i)->type() == dods_structure_c)
267 linear = linear && static_cast<Structure*>((*i))->
is_linear();
269 linear = linear && (*i)->is_simple_type();
279 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
280 (*i)->set_send_p(state);
289 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
290 (*i)->set_read_p(state);
305 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
306 (*i)->set_in_selection(state);
317 if ((*i)->type() == dods_sequence_c)
318 static_cast<Sequence&>(**i).set_leaf_sequence(++level);
319 else if ((*i)->type() == dods_structure_c)
320 static_cast<Structure&>(**i).set_leaf_sequence(level);
335 throw InternalErr(__FILE__, __LINE__,
"The BaseType parameter cannot be null.");
337 if (bt->is_dap4_only_type())
338 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Structure.");
347 d_vars.push_back(btp);
358 throw InternalErr(__FILE__, __LINE__,
"The BaseType parameter cannot be null.");
360 if (bt->is_dap4_only_type())
361 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Structure.");
364 d_vars.push_back(bt);
374 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
375 if ((*i)->name() == n) {
393 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
409 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
428 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
431 sz += (*i)->width(constrained);
434 sz += (*i)->width(constrained);
446 DBG(cerr <<
"Structure::intern_data: " <<
name() << endl);
450 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
451 if ((*i)->send_p()) {
452 (*i)->intern_data(eval, dds);
461 #if USE_LOCAL_TIMEOUT_SCHEME 471 #if USE_LOCAL_TIMEOUT_SCHEME 474 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
475 if ((*i)->send_p()) {
478 if (sm && sm->checksums() && (*i)->type() != dods_structure_c && (*i)->type() != dods_grid_c)
479 sm->reset_checksum();
481 (*i)->serialize(eval, dds, m,
false);
483 if (sm && sm->checksums() && (*i)->type() != dods_structure_c && (*i)->type() != dods_grid_c)
486 (*i)->serialize(eval, dds, m,
false);
497 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
498 (*i)->deserialize(um, dds, reuse);
537 return m_exact_match(n, s);
539 return m_leaf_match(n, s);
548 BaseType *btp = m_exact_match(name, &s);
552 return m_leaf_match(name, &s);
559 Structure::m_leaf_match(
const string &name, btp_stack *s)
561 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
562 if ((*i)->name() ==
name) {
564 DBG(cerr <<
"Pushing " << this->
name() << endl);
565 s->push(static_cast<BaseType *>(
this));
569 if ((*i)->is_constructor_type()) {
573 DBG(cerr <<
"Pushing " << this->
name() << endl);
574 s->push(static_cast<BaseType *>(
this));
588 Structure::m_exact_match(
const string &name, btp_stack *s)
591 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
592 if ((*i)->name() ==
name) {
594 s->push(static_cast<BaseType *>(
this));
602 string::size_type dot_pos = name.find(
".");
603 if (dot_pos != string::npos) {
604 string aggregate = name.substr(0, dot_pos);
605 string field = name.substr(dot_pos + 1);
610 s->push(static_cast<BaseType *>(
this));
612 return agg_ptr->
var(field,
true, s);
627 fwrite(oss.str().data(),
sizeof(char), oss.str().length(), out);
639 for (Vars_citer i = d_vars.begin(); i != d_vars.end();
640 i++, (void)(i != d_vars.end() && out <<
", ")) {
641 (*i)->print_val(out,
"",
false);
664 for (Vars_iter i = d_vars.begin(); i != d_vars.end(); i++) {
666 if (!(*i)->check_semantics(msg,
true)) {
689 strm << DapIndent::LMarg <<
"Structure::dump - (" 690 << (
void *)
this <<
")" << endl ;
691 DapIndent::Indent() ;
693 DapIndent::UnIndent() ;
virtual unsigned int width(bool constrained=false) const
virtual bool read_p()
Has this variable been read?
virtual string name() const
Returns the name of the class instance.
virtual void set_in_selection(bool state)
Set the in_selection property.
abstract base class used to unmarshall/deserialize dap data objects
AttrTable * get_AttrTable(const std::string name)
copy attributes from DAP4 to DAP2
virtual BaseType * ptr_duplicate()
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.
virtual void transform_to_dap4(D4Group *root, Constructor *container)
Contains the attributes for a dataset.
virtual string get_name() const
Get the name of this attribute table.
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
Structure(const string &n)
virtual vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table)
DAP4 to DAP2 transform.
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
virtual void print(FILE *out, string pad=" ", bool dereference=false)
Prints the attribute table.
Holds a structure (aggregate) type.
virtual void add_var(BaseType *bt, Part part=nil)
virtual void set_in_selection(bool state)
virtual int element_count(bool leaves=false)
Count the members of constructor types.
virtual void set_parent(BaseType *parent)
virtual void set_leaf_sequence(int level=1)
Traverse Structure, set Sequence leaf nodes.
A class for software fault reporting.
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Returns a pointer to a member of a constructor class.
virtual void transform_to_dap4(D4Group *root, Constructor *dest)
DAP2 to DAP4 transform.
virtual void set_send_p(bool state)
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net, then remove them from the object.
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 bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
virtual unsigned int val2buf(void *, bool)
Loads class data.
virtual void dump(ostream &strm) const
dumps information about this object
virtual BaseType * ptr_duplicate()=0
string www2id(const string &in, const string &escape, const string &except)
Evaluate a constraint expression.
virtual unsigned int buf2val(void **)
Reads the class data.
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.
virtual 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.
virtual void set_attr_table(const AttrTable &at)
virtual void dump(ostream &strm) const
dumps information about this object
bool eval_selection(DDS &dds, const std::string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator and is called ...
virtual void intern_data()
Read data into this variable.
virtual void del_var(const string &name)
virtual void set_send_p(bool state)
Marshaller that knows how serialize dap data objects to a C++ iostream using XDR. ...
virtual string dataset() const
Returns the name of the dataset used to create this instance.
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.