62 Constructor::Constructor(
const string &n,
const Type &t)
76 Constructor::Constructor(
const string &n,
const string &d,
const Type &t)
92 dynamic_cast<BaseType &
>(*this) = rhs;
103 return _vars.begin() ;
125 string::size_type i = source->
name.find(
"_dim_");
126 if (i != string::npos && (btp =
var(source->
name.substr(0, i)))) {
133 int n = atoi(source->
name.substr(i + 5).c_str());
134 DBG(cerr <<
"Found a Grid (" << btp->
name() <<
") and "
135 << source->
name.substr(i) <<
", extracted n: " << n << endl);
136 return *(
dynamic_cast<Grid&
>(*btp).map_begin() + n);
147 Constructor::find_matching_container(AttrTable::entry *source,
148 BaseType **dest_variable)
152 throw InternalErr(__FILE__, __LINE__,
"Constructor::find_matching_container");
157 if ((btp =
var(source->name))) {
159 *dest_variable = btp;
164 else if ((btp = find_hdf4_dimension_attribute_home(source))) {
168 DBG(cerr <<
"Found a Grid" << endl);
169 *dest_variable = btp;
170 return &btp->get_attr_table();
173 string::size_type i = source->name.find(
"_dim_");
174 string ext = source->name.substr(i + 1);
175 *dest_variable = btp;
176 return btp->get_attr_table().append_container(ext);
183 at =
new AttrTable();
213 DBG(cerr <<
"Constructor::transfer_attributes, variable: " <<
name() <<
215 DBG(cerr <<
"Working on the '" << entry->
216 name <<
"' container." << endl);
218 throw InternalErr(__FILE__, __LINE__,
219 "Constructor::transfer_attributes");
221 AttrTable *source = entry->attributes;
223 AttrTable *dest = find_matching_container(entry, &dest_variable);
227 while (source_p != source->attr_end()) {
228 DBG(cerr <<
"Working on the '" << (*source_p)->
229 name <<
"' attribute" << endl);
232 if (dest_variable && dest_variable->is_constructor_type()) {
233 dynamic_cast <Constructor & >(*dest_variable).transfer_attributes(*source_p);
236 dest->append_container(
new AttrTable(*(*source_p)->attributes),
241 dest->append_attr(source->get_name(source_p),
242 source->get_type(source_p),
243 source->get_attr_vector(source_p));
269 (*var)->transfer_attributes(at);
304 return _vars.rbegin();
321 return _vars.begin() + i;
330 return *(
_vars.begin() + i);
336 bool constraint_info,
bool constrained)
338 if (constrained && !
send_p())
341 fprintf(out,
"%s%s {\n", space.c_str(),
type_name().c_str()) ;
343 (*i)->print_decl(out, space +
" ",
true,
344 constraint_info, constrained);
346 fprintf(out,
"%s} %s", space.c_str(),
id2www(
name()).c_str()) ;
348 if (constraint_info) {
350 cout <<
": Send True";
352 cout <<
": Send False";
356 fprintf(out,
";\n") ;
362 bool constraint_info,
bool constrained)
364 if (constrained && !
send_p())
369 (*i)->print_decl(out, space +
" ",
true,
370 constraint_info, constrained);
374 if (constraint_info) {
376 out <<
": Send True";
378 out <<
": Send False";
386 class PrintField :
public unary_function<BaseType *, void>
392 PrintField(FILE *o,
string s,
bool c)
393 : d_out(o), d_space(s), d_constrained(c)
396 void operator()(BaseType *btp)
398 btp->print_xml(d_out, d_space, d_constrained);
405 if (constrained && !
send_p())
408 bool has_attributes =
false;
411 fprintf(out,
"%s<%s", space.c_str(),
type_name().c_str());
413 fprintf(out,
" name=\"%s\"",
id2xml(
name()).c_str());
415 if (has_attributes || has_variables) {
421 PrintField(out, space +
" ", constrained));
423 fprintf(out,
"%s</%s>\n", space.c_str(),
type_name().c_str());
426 fprintf(out,
"/>\n");
431 class PrintFieldStrm :
public unary_function<BaseType *, void>
437 PrintFieldStrm(ostream &o,
string s,
bool c)
438 : d_out(o), d_space(s), d_constrained(c)
441 void operator()(BaseType *btp)
443 btp->print_xml(d_out, d_space, d_constrained);
450 if (constrained && !
send_p())
453 bool has_attributes =
false;
460 if (has_attributes || has_variables) {
466 PrintFieldStrm(out, space +
" ", constrained));
468 out << space <<
"</" <<
type_name() <<
">\n" ;
505 << (
void *)
this <<
")" << endl ;
512 for (; i != ie; i++) {
std::vector< entry * >::iterator Attr_iter
virtual Attr_iter attr_end()
std::vector< BaseType * >::reverse_iterator Vars_riter
Contains the attributes for a dataset.
virtual string get_type(const string &name)
Get the type name of an attribute within this attribute table.
std::vector< BaseType * > _vars
std::vector< BaseType * >::iterator Vars_iter
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 void set_is_global_attribute(bool ga)
virtual AttrTable * find_container(const string &target)
Find an attribute with a given name.
Type
Identifies the data type.
Type type() const
Returns the type of the class instance.
virtual string get_name() const
Get the name of this attribute table.
Constructor & operator=(const Constructor &rhs)
virtual bool is_vector_type()
Returns true if the instance is a vector (i.e., array) type variable.
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Returns a pointer to a member of a constructor class.
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 transfer_attributes(AttrTable *at_container)
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual AttrTable * get_attr_table(const string &name)
Get an attribute container.
virtual void dump(ostream &strm) const
dumps information about this object
BaseType * get_var_index(int i)
virtual void dump(ostream &strm) const
dumps information about this object
string name() const
Returns the name of the class instance.
std::vector< BaseType * >::const_iterator Vars_citer
virtual Attr_iter attr_begin()
BaseType(const string &n, const Type &t)
The BaseType constructor.
static ostream & LMarg(ostream &strm)
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.
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 vector< string > * get_attr_vector(const string &name)
Get a vector-valued attribute.
Vars_iter get_vars_iter(int i)
virtual bool send_p()
Should this variable be sent?
string id2www(string in, const string &allowable)
void _duplicate(const Constructor &s)