57 Grid::_duplicate(
const Grid &s)
64 _vars.push_back(_array_var);
68 for (
Map_iter i = cs._map_vars.begin(); i != cs._map_vars.end(); i++) {
71 _map_vars.push_back(btp);
112 delete _array_var; _array_var = 0;
114 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
116 delete btp ; btp = 0;
123 return new Grid(*
this);
132 delete _array_var; _array_var = 0;
134 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
152 return _map_vars.size() + 1;
155 for (
Map_iter j = _map_vars.begin(); j != _map_vars.end(); j++) {
156 j += (*j)->element_count(leaves);
160 throw InternalErr(__FILE__, __LINE__,
"No Grid arry!");
172 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
173 (*i)->set_send_p(state);
184 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
185 (*i)->set_read_p(state);
196 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
197 (*i)->set_in_selection(state);
206 unsigned int sz = _array_var->
width();
208 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
228 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
229 if ((*i)->send_p()) {
230 (*i)->intern_data(eval, dds);
256 _array_var->
serialize(eval, dds, m,
false);
258 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
259 if ((*i)->send_p()) {
260 (*i)->serialize(eval, dds, m,
false);
272 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
273 (*i)->deserialize(um, dds, reuse);
304 return var(n,
true, &s);
318 s->push(static_cast<BaseType *>(
this));
322 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
323 if ((*i)->name() ==
name) {
325 s->push(static_cast<BaseType *>(
this));
350 "Passing NULL pointer as variable to be added.");
353 if (part ==
array && _array_var) {
355 throw InternalErr(__FILE__, __LINE__,
"Error: Grid::add_var called with part==Array, but the array was already set!");
369 "Grid::add_var(): with Part==array: object is not an Array!");
373 set_array(static_cast<Array*>(bt_clone));
380 _map_vars.push_back(bt_clone);
391 "Grid::add_var(): with Part==array: object is not an Array!");
395 set_array(static_cast<Array*>(bt_clone));
400 _map_vars.push_back(bt_clone);
410 _vars.push_back(bt_clone);
428 "Grid::set_array(): Cannot set to null!");
431 if (p_new_arr == _array_var) {
435 delete _array_var; _array_var = 0;
437 _array_var = p_new_arr;
472 "Grid::add_map(): cannot have p_new_map null!");
480 _map_vars.push_back(p_new_map);
481 _vars.push_back(p_new_map);
508 _map_vars.insert(_map_vars.begin(), p_new_map);
541 return _map_vars.begin() ;
549 return _map_vars.end() ;
556 return _map_vars.rbegin() ;
564 return _map_vars.rend() ;
573 return _map_vars.begin() + i;
597 comp = _array_var->
send_p() ? 1 : 0;
599 for (
Map_iter i = _map_vars.begin(); i != _map_vars.end(); i++) {
600 if ((*i)->send_p()) {
606 comp = 1 + _map_vars.size();
623 (*map)->transfer_attributes(at);
720 bool constraint_info,
bool constrained)
722 if (constrained && !
send_p())
731 fprintf(out,
"%sStructure {\n", space.c_str()) ;
733 _array_var->
print_decl(out, space +
" ",
true, constraint_info,
736 for (
Map_citer i = _map_vars.begin(); i != _map_vars.end(); i++) {
737 (*i)->print_decl(out, space +
" ",
true,
738 constraint_info, constrained);
741 fprintf(out,
"%s} %s", space.c_str(),
id2www(
name()).c_str()) ;
746 fprintf(out,
"%s%s {\n", space.c_str(),
type_name().c_str()) ;
748 fprintf(out,
"%s Array:\n", space.c_str()) ;
749 _array_var->
print_decl(out, space +
" ",
true, constraint_info,
752 fprintf(out,
"%s Maps:\n", space.c_str()) ;
753 for (
Map_citer i = _map_vars.begin(); i != _map_vars.end(); i++) {
754 (*i)->print_decl(out, space +
" ",
true,
755 constraint_info, constrained);
758 fprintf(out,
"%s} %s", space.c_str(),
id2www(
name()).c_str()) ;
761 if (constraint_info) {
763 fprintf( out,
": Send True");
765 fprintf( out,
": Send False");
769 fprintf(out,
";\n") ;
777 bool constraint_info,
bool constrained)
779 if (constrained && !
send_p())
784 out << space <<
"Structure {\n" ;
786 _array_var->
print_decl(out, space +
" ",
true, constraint_info,
789 for (
Map_citer i = _map_vars.begin(); i != _map_vars.end(); i++) {
790 (*i)->print_decl(out, space +
" ",
true,
791 constraint_info, constrained);
801 out << space <<
" Array:\n" ;
802 _array_var->
print_decl(out, space +
" ",
true, constraint_info,
805 out << space <<
" Maps:\n" ;
806 for (
Map_citer i = _map_vars.begin(); i != _map_vars.end(); i++) {
807 (*i)->print_decl(out, space +
" ",
true,
808 constraint_info, constrained);
814 if (constraint_info) {
816 out <<
": Send True";
818 out <<
": Send False";
828 class PrintMapField :
public unary_function<BaseType *, void>
835 PrintMapField(FILE *o,
string s,
bool c,
const string &t =
"Map")
836 : d_out(o), d_space(s), d_constrained(c), d_tag(t)
839 void operator()(BaseType *btp)
841 Array *a =
dynamic_cast<Array*
>(btp);
843 throw InternalErr(__FILE__, __LINE__,
"Expected an Array.");
844 a->print_xml_core(d_out, d_space, d_constrained, d_tag);
851 if (constrained && !
send_p())
855 fprintf(out,
"%s<Structure", space.c_str());
857 fprintf(out,
" name=\"%s\"",
id2xml(
name()).c_str());
866 PrintMapField(out, space +
" ", constrained,
"Array"));
868 fprintf(out,
"%s</Structure>\n", space.c_str());
873 fprintf(out,
"%s<Grid", space.c_str());
875 fprintf(out,
" name=\"%s\"",
id2xml(
name()).c_str());
884 PrintMapField(out, space +
" ", constrained));
886 fprintf(out,
"%s</Grid>\n", space.c_str());
891 class PrintMapFieldStrm :
public unary_function<BaseType *, void>
898 PrintMapFieldStrm(ostream &o,
string s,
bool c,
const string &t =
"Map")
899 : d_out(o), d_space(s), d_constrained(c), d_tag(t)
902 void operator()(BaseType *btp)
904 Array *a =
dynamic_cast<Array*
>(btp);
906 throw InternalErr(__FILE__, __LINE__,
"Expected an Array.");
907 a->print_xml_core(d_out, d_space, d_constrained, d_tag);
914 if (constrained && !
send_p())
918 out << space <<
"<Structure" ;
929 PrintMapFieldStrm(out, space +
" ", constrained,
"Array"));
931 out << space <<
"</Structure>\n" ;
936 out << space <<
"<Grid" ;
947 PrintMapFieldStrm(out, space +
" ", constrained));
949 out << space <<
"</Grid>\n" ;
959 fprintf(out,
" = ") ;
968 fprintf(out,
"{ Array: ") ;
973 fprintf(out,
" Maps: ") ;
974 for (
Map_citer i = _map_vars.begin(); i != _map_vars.end();
975 i++, (void)(i != _map_vars.end() && fprintf(out,
", "))) {
976 (*i)->print_val(out,
"",
false);
981 fprintf(out,
";\n") ;
1005 for (
Map_citer i = _map_vars.begin(); i != _map_vars.end();
1006 i++, (void)(i != _map_vars.end() && out <<
", ")) {
1007 (*i)->print_val(out,
"",
false);
1030 msg +=
"Null grid base array in `" +
name() +
"'\n";
1036 msg +=
"Grid `" +
name() +
"'s' member `" + _array_var->
name() +
"' must be an array\n";
1044 msg +=
"The field variable `" + this->
name() +
"' must be an array of simple type elements (e.g., int32, String)\n";
1049 if ((
unsigned)_map_vars.size() != av->
dimensions()) {
1050 msg +=
"The number of map variables for grid `" + this->
name() +
"' does not match the number of dimensions of `";
1051 msg += av->
name() +
"'\n";
1055 const string array_var_name = av->
name();
1057 for (
Map_iter mvi = _map_vars.begin();
1058 mvi != _map_vars.end(); mvi++, asi++) {
1063 if (array_var_name == mv->
name()) {
1064 msg +=
"Grid map variable `" + mv->
name() +
"' conflicts with the grid array name in grid `" +
name() +
"'\n";
1069 msg +=
"Grid map variable `" + mv->
name() +
"' is not an array\n";
1077 msg +=
"The field variable `" + this->
name() +
"' must be an array of simple type elements (e.g., int32, String)\n";
1083 msg +=
"Grid map variable `" + mv_a->
name() +
"' must be only one dimension\n";
1090 if (mv_a_size != av_size) {
1091 msg +=
"Grid map variable `" + mv_a->
name() +
"'s' size does not match the size of array variable '";
1092 msg += _array_var->
name() +
"'s' cooresponding dimension\n";
1100 for (
Map_iter mvi = _map_vars.begin(); mvi != _map_vars.end(); mvi++) {
1101 if (!(*mvi)->check_semantics(msg,
true)) {
1122 << (
void *)
this <<
")" << endl ;
1128 _array_var->
dump(strm) ;
1138 for (; i != ie; i++) {
std::vector< entry * >::iterator Attr_iter
virtual bool read()
Read data into a local buffer.
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.
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)
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.
virtual unsigned int width()
Returns the size of the class instance data.
Grid & operator=(const Grid &rhs)
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)
std::vector< BaseType * > _vars
virtual void print_xml(FILE *out, string pad=" ", bool constrained=false)
virtual bool is_global_attribute() const
string id2xml(string in, const string ¬_allowed)
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)=0
Move data to the net.
virtual unsigned int width()=0
Returns the size of the class instance data.
virtual void set_in_selection(bool state)
virtual int element_count(bool leaves)
Count the members of constructor types.
virtual void set_is_global_attribute(bool ga)
virtual void set_send_p(bool state)
Type type() const
Returns the type of the class instance.
virtual unsigned int val2buf(void *buf, bool reuse=false)
Returns the size of the Grid type.
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 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
std::vector< BaseType * >::reverse_iterator Map_riter
string name() const
Returns the name of the class instance.
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
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.
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
virtual unsigned int buf2val(void **val)
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.
virtual bool is_simple_type()
Returns true if the instance is a numeric, string or URL type variable.
void _duplicate(const Grid &s)
BaseType * array_var()
Returns the Grid Array.
virtual void transfer_attributes(AttrTable *at)
A multidimensional array of identical data types.
virtual bool send_p()
Should this variable be sent?
Grid(const string &n)
The Grid constructor.
string id2www(string in, const string &allowable)
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.