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++) {