64 Grid::m_duplicate(
const Grid &s)
72 d_is_array_set = s.d_is_array_set;
116 return new Grid(*
this);
127 delete d_array_var; d_array_var = 0;
129 for (
Map_iter i = d_map_vars.begin(); i != d_map_vars.end(); i++) {
153 throw InternalErr(__FILE__, __LINE__,
"Expected an Array while transforming a Grid (coverage)");
164 throw InternalErr(__FILE__, __LINE__,
"Expected an Array while transforming a Grid (map)");
180 "transform_to_dap4() returned a null value where there can be no Grid.");
221 throw InternalErr(__FILE__, __LINE__,
"Passing NULL pointer as variable to be added.");
223 if (part ==
array && d_is_array_set) {
225 throw InternalErr(__FILE__, __LINE__,
"Error: Grid::add_var called with part==Array, but the array was already set!");
229 if (!dynamic_cast<Array*>(bt)) {
230 throw InternalErr(__FILE__, __LINE__,
"Grid::add_var(): object is not an Array!");
241 set_array(static_cast<Array*>(bt_clone));
248 d_vars.push_back(bt_clone);
253 if (!d_is_array_set) {
256 set_array(static_cast<Array*>(bt_clone));
261 d_vars.push_back(bt_clone);
287 throw InternalErr(__FILE__, __LINE__,
"Passing NULL pointer as variable to be added.");
289 if (part ==
array && d_is_array_set) {
291 throw InternalErr(__FILE__, __LINE__,
"Error: Grid::add_var called with part==Array, but the array was already set!");
295 if (!dynamic_cast<Array*>(bt)) {
296 throw InternalErr(__FILE__, __LINE__,
"Grid::add_var(): object is not an Array!");
317 if (!d_is_array_set) {
346 throw InternalErr(__FILE__, __LINE__,
"Grid::set_array(): Cannot set to null!");
361 d_vars.push_back(p_new_arr);
363 else if (!d_is_array_set) {
372 d_is_array_set =
true;
375 d_array_var = p_new_arr;
412 throw InternalErr(__FILE__, __LINE__,
"Grid::add_map(): cannot have p_new_map null!");
419 d_vars.push_back(p_new_map);
461 cerr <<
"In array_var(), d_array_var holds a " << d_array_var->
type_name() << endl;
463 cerr <<
"In array_var(), d_array_var is null" << endl;
465 return d_is_array_set ? *
d_vars.begin() : 0;
485 return d_is_array_set ?
d_vars.begin() + 1:
d_vars.begin();
510 return d_is_array_set ?
d_vars.rend() - 1:
d_vars.rend();
547 if ((*i)->send_p()) {
570 (*map)->transfer_attributes(at);
664 bool constraint_info,
bool constrained)
667 print_decl(oss, space, print_semi, constraint_info, constrained);
668 fwrite(oss.str().data(),
sizeof(char), oss.str().length(), out);
673 bool constraint_info,
bool constrained)
675 if (constrained && !
send_p())
680 out << space <<
"Structure {\n" ;
686 (*i)->print_decl(out, space +
" ",
true,
687 constraint_info, constrained);
697 out << space <<
" Array:\n" ;
701 out << space <<
" Maps:\n" ;
703 (*i)->print_decl(out, space +
" ",
true,
704 constraint_info, constrained);
710 if (constraint_info) {
712 out <<
": Send True";
714 out <<
": Send False";
746 class PrintGridFieldXMLWriter :
public unary_function<BaseType *, void>
752 PrintGridFieldXMLWriter(
XMLWriter &x,
bool c,
const string &t =
"Map")
753 : d_xml(x), d_constrained(c), d_tag(t)
756 void operator()(BaseType *btp)
758 Array *a =
dynamic_cast<Array*
>(btp);
760 throw InternalErr(__FILE__, __LINE__,
"Expected an Array.");
761 a->print_xml_writer_core(d_xml, d_constrained, d_tag);
768 if (constrained && !
send_p())
772 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"Structure") < 0)
773 throw InternalErr(__FILE__, __LINE__,
"Could not write Structure element");
776 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
777 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
784 PrintGridFieldXMLWriter(xml, constrained,
"Array"));
786 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
787 throw InternalErr(__FILE__, __LINE__,
"Could not end Structure element");
792 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"Grid") < 0)
793 throw InternalErr(__FILE__, __LINE__,
"Could not write Grid element");
796 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
797 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
804 PrintGridFieldXMLWriter(xml, constrained,
"Map"));
806 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
807 throw InternalErr(__FILE__, __LINE__,
"Could not end Grid element");
816 fwrite(oss.str().data(),
sizeof(char), oss.str().length(), out);
840 (*i)->print_val(out,
"",
false);
863 msg +=
"Null grid base array in `" +
name() +
"'\n";
869 msg +=
"Grid `" +
name() +
"'s' member `" +
get_array()->
name() +
"' must be an array\n";
877 msg +=
"The field variable `" + this->
name() +
"' must be an array of simple type elements (e.g., int32, String)\n";
883 msg +=
"The number of map variables for grid `" + this->
name() +
"' does not match the number of dimensions of `";
884 msg += av->
name() +
"'\n";
888 const string array_var_name = av->
name();
895 if (array_var_name == mv->
name()) {
896 msg +=
"Grid map variable `" + mv->
name() +
"' conflicts with the grid array name in grid `" +
name() +
"'\n";
901 msg +=
"Grid map variable `" + mv->
name() +
"' is not an array\n";
909 msg +=
"The field variable `" + this->
name() +
"' must be an array of simple type elements (e.g., int32, String)\n";
915 msg +=
"Grid map variable `" + mv_a->
name() +
"' must be only one dimension\n";
922 if (mv_a_size != av_size) {
923 msg +=
"Grid map variable `" + mv_a->
name() +
"'s' size does not match the size of array variable '";
924 msg +=
get_array()->
name() +
"'s' cooresponding dimension\n";
933 if (!(*mvi)->check_semantics(msg,
true)) {
954 << (
void *)
this <<
")" << endl ;
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
std::vector< entry * >::iterator Attr_iter
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)
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 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 void print_xml(ostream &out, string space=" ", bool constrained=false)
virtual bool is_global_attribute() const
virtual void set_is_global_attribute(bool ga)
void print_xml_writer(XMLWriter &xml)
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
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_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)
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
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 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 BaseType * ptr_duplicate()
virtual int dimension_stride(Dim_iter i, bool constrained=false)
Returns the stride value of the constraint.
Holds the Grid data type.
virtual void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Prints a DDS entry for the Array.
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
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
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.
static ostream & LMarg(ostream &strm)
virtual bool is_simple_type() const
Returns true if the instance is a numeric, string or URL type variable.
virtual int dimension_start(Dim_iter i, bool constrained=false)
Return the start index of a dimension.
virtual AttrTable & get_attr_table()
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.
void m_duplicate(const Grid &s)
virtual bool check_semantics(string &msg, bool all=false)
Return true if this Grid is well formed.
virtual vector< string > * get_attr_vector(const string &name)
Get a vector-valued attribute.
BaseType * array_var()
Returns the Grid Array.
virtual BaseType * transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.
virtual void transfer_attributes(AttrTable *at)
A multidimensional array of identical data types.
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
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 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.
virtual BaseType * transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.