32#include <libdap/util.h>
33#include <libdap/Array.h>
34#include <BESInternalError.h>
37#include "FONcStructure.h"
39#include "FONcAttributes.h"
52 _s =
dynamic_cast<Structure *
>(b);
54 string s = (
string)
"File out netcdf, write_structure was passed a " +
"variable that is not a structure";
58 for (
const auto &bt:_s->variables()) {
60 Type t_bt = bt->type();
62 if (libdap::is_simple_type(t_bt) == false) {
64 if (t_bt != dods_array_c) {
65 can_handle_str_memb = false;
69 auto t_a = dynamic_cast<Array *>(bt);
70 Type t_array_var = t_a->var()->type();
71 if (!libdap::is_simple_type(t_array_var) || t_array_var == dods_url_c || t_array_var == dods_enum_c || t_array_var==dods_opaque_c) {
72 can_handle_str_memb = false;
77 else if (t_bt == dods_url_c || t_bt == dods_enum_c || t_bt==dods_opaque_c) {
78 can_handle_str_memb =
false;
101 FONcBaseType *b = (*i);
129 if (can_handle_str_memb) {
133 _s->intern_data(*get_eval(),*get_dds());
136 FONcBaseType::convert(embed,_dap4,is_dap4_group);
137 embed.push_back(
name());
138 Constructor::Vars_iter vi = _s->var_begin();
139 Constructor::Vars_iter ve = _s->var_end();
140 for (; vi != ve; vi++) {
143 BESDEBUG(
"fonc",
"FONcStructure::convert - converting " << bt->name() << endl);
144 bool is_classic_model =
true;
145 if(
true == isNetCDF4_ENHANCED())
146 is_classic_model =
false;
147 FONcBaseType *fbt = FONcUtils::convert(bt, this->d_ncVersion, is_classic_model);
148 _vars.push_back(fbt);
149 fbt->convert(embed,_dap4,is_dap4_group);
172 BESDEBUG(
"fonc",
"FONcStructure::define - defining " << d_varname << endl);
176 for (; i != e; i++) {
177 FONcBaseType *fbt = (*i);
178 BESDEBUG(
"fonc",
"defining " << fbt->name() << endl);
184 BESDEBUG(
"fonc",
"FONcStructure::define - done defining " << d_varname << endl);
198 if (can_handle_str_memb ==
false) {
202 _s->intern_data(*get_eval(),*get_dds());
204 BESDEBUG(
"fonc",
"FONcStructure::write - writing " << d_varname << endl);
207 for (; i != e; i++) {
208 FONcBaseType *fbt = (*i);
210 fbt->set_dds(get_dds());
211 fbt->set_eval(get_eval());
216 BESDEBUG(
"fonc",
"FONcStructure::define - done writing " << d_varname << endl);
238 strm << BESIndent::LMarg <<
"FONcStructure::dump - (" << (
void *)
this <<
")" << endl;
240 strm << BESIndent::LMarg <<
"name = " << _s->name() <<
" {" << endl;
244 for (; i != e; i++) {
245 FONcBaseType *fbt = *i;
248 BESIndent::UnIndent();
249 strm << BESIndent::LMarg <<
"}" << endl;
250 BESIndent::UnIndent();
exception thrown if internal error encountered
virtual void define(int ncid)
Define the variable in the netcdf file.
void dump(std::ostream &strm) const override=0
dump the contents of this object to the specified ostream
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
virtual void define(int ncid)
Define the members of the structure in the netcdf file.
FONcStructure(libdap::BaseType *b)
Constructor for FONcStructure that takes a DAP Structure.
virtual void write(int ncid)
write the member variables of the structure to the netcdf file
virtual string name()
Returns the name of the structure.
virtual void convert(vector< string > embed, bool _dap4=false, bool is_dap4_group=false)
Creates the FONc objects for each variable of the DAP structure.
virtual ~FONcStructure()
Destructor that cleans up the structure.