58 Grid::m_duplicate(
const Grid &s)
65 d_vars.push_back(d_array_var);
69 for (
Map_iter i = cs.d_map_vars.begin(); i != cs.d_map_vars.end(); i++) {
72 d_map_vars.push_back(btp);
73 d_vars.push_back(btp);
113 delete d_array_var; d_array_var = 0;
115 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
117 delete btp ; btp = 0;
124 return new Grid(*
this);
133 delete d_array_var; d_array_var = 0;
135 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
164 return d_map_vars.size() + 1;
167 for (
Map_iter j = d_map_vars.begin(); j != d_map_vars.end(); j++) {
168 j += (*j)->element_count(leaves);
172 throw InternalErr(__FILE__, __LINE__,
"No Grid array!");
184 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
185 (*i)->set_send_p(state);
196 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
197 (*i)->set_read_p(state);
208 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
209 (*i)->set_in_selection(state);
218 unsigned int sz = d_array_var->
width();
220 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
240 if (d_array_var->
send_p())
241 sz = d_array_var->
width(constrained);
244 sz = d_array_var->
width(constrained);
247 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
250 sz += (*i)->width(constrained);
253 sz += (*i)->width(constrained);
270 if (d_array_var->
send_p())
273 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
274 if ((*i)->send_p()) {
275 (*i)->intern_data(eval, dds);
283 DBG(cerr <<
"In Grid::serialize()" << endl);
290 DBG(cerr <<
"In Grid::serialize(), before read() - read_p() returned: " <<
read_p() << endl);
295 DBG(cerr <<
"In Grid::serialize(), past read() - read_p() returned: " <<
read_p() << endl);
304 if (d_array_var->
send_p()) {
307 if (sm && sm->checksums())
308 sm->reset_checksum();
310 d_array_var->
serialize(eval, dds, m,
false);
312 if (sm && sm->checksums())
315 DBG(cerr <<
"About to call Array::serialize() in Grid::serialize" << endl);
316 d_array_var->
serialize(eval, dds, m,
false);
320 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
321 if ((*i)->send_p()) {
324 if (sm && sm->checksums())
325 sm->reset_checksum();
327 (*i)->serialize(eval, dds, m,
false);
329 if (sm && sm->checksums())
332 (*i)->serialize(eval, dds, m,
false);
345 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
346 (*i)->deserialize(um, dds, reuse);
379 return var(n,
true, &s);
393 s->push(static_cast<BaseType *>(
this));
397 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
398 if ((*i)->name() ==
name) {
400 s->push(static_cast<BaseType *>(
this));
424 throw InternalErr(__FILE__, __LINE__,
"Passing NULL pointer as variable to be added.");
426 if (bt->is_dap4_only_type())
427 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Grid.");
429 if (part ==
array && d_array_var) {
431 throw InternalErr(__FILE__, __LINE__,
"Error: Grid::add_var called with part==Array, but the array was already set!");
445 "Grid::add_var(): with Part==array: object is not an Array!");
449 set_array(static_cast<Array*>(bt_clone));
456 d_map_vars.push_back(bt_clone);
467 "Grid::add_var(): with Part==array: object is not an Array!");
471 set_array(static_cast<Array*>(bt_clone));
476 d_map_vars.push_back(bt_clone);
486 d_vars.push_back(bt_clone);
509 throw InternalErr(__FILE__, __LINE__,
"Passing NULL pointer as variable to be added.");
511 if (bt->is_dap4_only_type())
512 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Grid.");
514 if (part ==
array && d_array_var) {
516 throw InternalErr(__FILE__, __LINE__,
"Error: Grid::add_var called with part==Array, but the array was already set!");
529 "Grid::add_var(): with Part==array: object is not an Array!");
537 d_map_vars.push_back(bt);
548 "Grid::add_var(): with Part==array: object is not an Array!");
553 d_map_vars.push_back(bt);
581 "Grid::set_array(): Cannot set to null!");
584 if (p_new_arr == d_array_var) {
588 delete d_array_var; d_array_var = 0;
590 d_array_var = p_new_arr;
624 throw InternalErr(__FILE__, __LINE__,
"Grid::add_map(): cannot have p_new_map null!");
626 if (p_new_map->is_dap4_only_type())
627 throw InternalErr(__FILE__, __LINE__,
"Attempt to add a DAP4 type to a DAP2 Grid.");
633 d_map_vars.push_back(p_new_map);
634 d_vars.push_back(p_new_map);
661 d_map_vars.insert(d_map_vars.begin(), p_new_map);
694 return d_map_vars.begin() ;
702 return d_map_vars.end() ;
709 return d_map_vars.rbegin() ;
717 return d_map_vars.rend() ;
726 return d_map_vars.begin() + i;
750 comp = d_array_var->
send_p() ? 1 : 0;
752 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
753 if ((*i)->send_p()) {
759 comp = 1 + d_map_vars.size();
776 (*map)->transfer_attributes(at);
872 bool constraint_info,
bool constrained)
875 print_decl(oss, space, print_semi, constraint_info, constrained);
876 fwrite(oss.str().data(),
sizeof(char), oss.str().length(), out);
881 bool constraint_info,
bool constrained)
883 if (constrained && !
send_p())
888 out << space <<
"Structure {\n" ;
890 d_array_var->
print_decl(out, space +
" ",
true, constraint_info,
893 for (
Map_citer i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
894 (*i)->print_decl(out, space +
" ",
true,
895 constraint_info, constrained);
905 out << space <<
" Array:\n" ;
906 d_array_var->
print_decl(out, space +
" ",
true, constraint_info,
909 out << space <<
" Maps:\n" ;
910 for (
Map_citer i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
911 (*i)->print_decl(out, space +
" ",
true,
912 constraint_info, constrained);
918 if (constraint_info) {
920 out <<
": Send True";
922 out <<
": Send False";
954 class PrintGridFieldXMLWriter :
public unary_function<BaseType *, void>
960 PrintGridFieldXMLWriter(
XMLWriter &x,
bool c,
const string &t =
"Map")
961 : d_xml(x), d_constrained(c), d_tag(t)
964 void operator()(BaseType *btp)
966 Array *a =
dynamic_cast<Array*
>(btp);
968 throw InternalErr(__FILE__, __LINE__,
"Expected an Array.");
969 a->print_xml_writer_core(d_xml, d_constrained, d_tag);
976 if (constrained && !
send_p())
980 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"Structure") < 0)
981 throw InternalErr(__FILE__, __LINE__,
"Could not write Structure element");
984 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
985 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
992 PrintGridFieldXMLWriter(xml, constrained,
"Array"));
994 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
995 throw InternalErr(__FILE__, __LINE__,
"Could not end Structure element");
1000 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"Grid") < 0)
1001 throw InternalErr(__FILE__, __LINE__,
"Could not write Grid element");
1003 if (!
name().empty())
1004 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
1005 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
1012 PrintGridFieldXMLWriter(xml, constrained,
"Map"));
1014 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
1015 throw InternalErr(__FILE__, __LINE__,
"Could not end Grid element");
1024 fwrite(oss.str().data(),
sizeof(char), oss.str().length(), out);
1041 out <<
"{ Array: " ;
1047 for (
Map_citer i = d_map_vars.begin(); i != d_map_vars.end();
1048 i++, (void)(i != d_map_vars.end() && out <<
", ")) {
1049 (*i)->print_val(out,
"",
false);
1072 msg +=
"Null grid base array in `" +
name() +
"'\n";
1078 msg +=
"Grid `" +
name() +
"'s' member `" + d_array_var->
name() +
"' must be an array\n";
1086 msg +=
"The field variable `" + this->
name() +
"' must be an array of simple type elements (e.g., int32, String)\n";
1091 if ((
unsigned)d_map_vars.size() != av->
dimensions()) {
1092 msg +=
"The number of map variables for grid `" + this->
name() +
"' does not match the number of dimensions of `";
1093 msg += av->
name() +
"'\n";
1097 const string array_var_name = av->
name();
1099 for (
Map_iter mvi = d_map_vars.begin();
1100 mvi != d_map_vars.end(); mvi++, asi++) {
1105 if (array_var_name == mv->
name()) {
1106 msg +=
"Grid map variable `" + mv->
name() +
"' conflicts with the grid array name in grid `" +
name() +
"'\n";
1111 msg +=
"Grid map variable `" + mv->
name() +
"' is not an array\n";
1119 msg +=
"The field variable `" + this->
name() +
"' must be an array of simple type elements (e.g., int32, String)\n";
1125 msg +=
"Grid map variable `" + mv_a->
name() +
"' must be only one dimension\n";
1132 if (mv_a_size != av_size) {
1133 msg +=
"Grid map variable `" + mv_a->
name() +
"'s' size does not match the size of array variable '";
1134 msg += d_array_var->
name() +
"'s' cooresponding dimension\n";
1142 for (
Map_iter mvi = d_map_vars.begin(); mvi != d_map_vars.end(); mvi++) {
1143 if (!(*mvi)->check_semantics(msg,
true)) {
1164 << (
void *)
this <<
")" << endl ;
1170 d_array_var->
dump(strm) ;
1180 for (; i != ie; i++) {
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
std::vector< entry * >::iterator Attr_iter
virtual bool read_p()
Has this variable been read?
abstract base class used to unmarshall/deserialize dap data objects
virtual void print_decl(FILE *out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
xmlTextWriterPtr get_writer()
virtual Attr_iter attr_end()
virtual unsigned int dimensions(bool constrained=false)
Return the total number of dimensions in the array.
virtual Array * prepend_map(Array *p_new_map, bool add_copy)
virtual void add_var_nocopy(BaseType *bt, Part part)
Part
Names the parts of multi-section constructor data types.
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net.
virtual void dump(ostream &strm) const
dumps information about this object
Contains the attributes for a dataset.
Grid & operator=(const Grid &rhs)
std::vector< BaseType * > d_vars
virtual string get_type(const string &name)
Get the type name of an attribute within this attribute table.
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)=0
Receive data from the net.
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
virtual bool is_global_attribute() const
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)=0
Move data to the net.
virtual void set_in_selection(bool state)
Set the in_selection property.
virtual int element_count(bool leaves)
Count the members of constructor types.
virtual void set_is_global_attribute(bool ga)
void print_xml_writer(XMLWriter &xml)
virtual void set_send_p(bool state)
Type type() const
Returns the type of the class instance.
virtual string get_name() const
Get the name of this attribute table.
virtual void set_in_selection(bool state)
stack< BaseType * > btp_stack
virtual void set_parent(BaseType *parent)
A class for software fault reporting.
std::vector< BaseType * >::const_iterator Map_citer
virtual int components(bool constrained=false)
Returns the number of components in the Grid object.
Map_riter map_rbegin()
Returns an iterator referencing the first Map vector.
virtual void set_array(Array *p_new_arr)
string dataset() const
Returns the name of the dataset used to create this instance.
bool eval_selection(DDS &dds, const string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called ...
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
virtual int element_count(bool leaves=false)
Count the members of constructor types.
virtual bool projection_yields_grid()
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
string type_name() const
Returns the type of the class instance as a string.
virtual int dimension_size(Dim_iter i, bool constrained=false)
Returns the size of the dimension.
virtual BaseType * ptr_duplicate()
Map_iter get_map_iter(int i)
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
virtual void set_send_p(bool state)
virtual void add_var(BaseType *bt, Part part)
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual void transfer_attributes(AttrTable *at_container)
virtual void clear_constraint()
virtual AttrTable * get_attr_table(const string &name)
Get an attribute container.
std::vector< dimension >::iterator Dim_iter
virtual void dump(ostream &strm) const
dumps information about this object
virtual void set_read_p(bool state)
Sets the value of the read_p property.
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
virtual BaseType * ptr_duplicate()
virtual int dimension_stride(Dim_iter i, bool constrained=false)
Returns the stride value of the constraint.
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Holds the Grid data type.
virtual void dump(ostream &strm) const
dumps information about this object
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
virtual Array * add_map(Array *p_new_map, bool add_copy)
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required...
std::vector< BaseType * >::iterator Map_iter
virtual unsigned int val2buf(void *, bool)
Loads class data.
std::vector< BaseType * >::reverse_iterator Map_riter
string name() const
Returns the name of the class instance.
virtual bool is_dap2_only_type()
virtual Attr_iter attr_begin()
virtual BaseType * ptr_duplicate()=0
string www2id(const string &in, const string &escape, const string &except)
virtual int dimension_stop(Dim_iter i, bool constrained=false)
Return the stop index of the constraint.
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.
Evaluate a constraint expression.
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
virtual unsigned int buf2val(void **)
Reads the class data.
static ostream & LMarg(ostream &strm)
virtual int dimension_start(Dim_iter i, bool constrained=false)
Return the start index of a dimension.
virtual AttrTable & get_attr_table()
virtual BaseType * var(const string &n, bool exact=true, btp_stack *s=0)
virtual unsigned int append_attr(const string &name, const string &type, const string &value)
Add an attribute to the table.
The basic data type for the DODS DAP types.
virtual AttrType get_attr_type(const string &name)
Get the type of an attribute.
abstract base class used to marshal/serialize dap data objects
void m_duplicate(const Grid &s)
virtual bool check_semantics(string &msg, bool all=false)
Return true if this Grid is well formed.
virtual unsigned int width(bool constrained=false)
virtual vector< string > * get_attr_vector(const string &name)
Get a vector-valued attribute.
virtual bool is_simple_type()
Returns true if the instance is a numeric, string or URL type variable.
BaseType * array_var()
Returns the Grid Array.
virtual void transfer_attributes(AttrTable *at)
virtual unsigned int width(bool constrained=false)
marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using XDR ...
A multidimensional array of identical data types.
virtual bool send_p()
Should this variable be sent?
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Grid(const string &n)
The Grid constructor.
string id2www(string in, const string &allowable)
unsigned int get_doc_size()
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)=0
Prints the value of the variable.
virtual void clear_constraint()
Clears the projection; add each projected dimension explicitly using add_constraint.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.