function mgffncvariable::_getAttribute, name, found=found
compile_opt strictarr
found = 0B
return, !null
end
pro mgffncgroup::getProperty, attributes=attributes, $
groups=groups, $
variables=variables, $
name=name, $
fullname=fullname, $
_ref_extra=e
compile_opt strictarr
if (arg_present(attributes)) then attributes = !null
if (arg_present(groups)) then begin
group_ids = ncdf_groupsinq(self.id)
if (group_ids[0] eq -1L) then begin
groups = !null
endif else begin
groups = strarr(n_elements(group_ids))
for g = 0L, n_elements(group_ids) - 1L do begin
groups[g] = ncdf_groupname(group_ids[g])
endfor
endelse
endif
if (arg_present(variables)) then begin
var_ids = ncdf_varidsinq(self.id)
if (var_ids[0] eq -1L) then begin
variables = !null
endif else begin
variables = strarr(n_elements(var_ids))
for v = 0L, n_elements(var_ids) - 1L do begin
var_info = ncdf_varinq(self.id, var_ids[v])
variables[v] = var_info.name
endfor
endelse
endif
if (arg_present(name)) then name = ncdf_groupname(self.id)
if (arg_present(fullname)) then fullname = ncdf_fullgroupname(self.id)
if (n_elements(e) gt 0L) then self->MGffNCBase::getProperty, _extra=e
end
function mgffncgroup::_overloadHelp, varname
compile_opt strictarr
type = 'NCGroup'
specs = string(ncdf_fullgroupname(self.id), format='(%"%s")')
return, self->MGffNCBase::_overloadHelp(varname, type=type, specs=specs)
end
function mgffncgroup::dump, indent=indent
compile_opt strictarr
result = ''
_indent = n_elements(indent) eq 0L ? '' : indent
result += string(_indent eq '' ? '' : mg_newline(), _indent, $
ncdf_groupname(self.id), $
format='(%"%s%s+ GROUP %s")')
self->getProperty, attributes=attributes
foreach att_name, attributes do begin
result += string(mg_newline(), _indent, att_name, format='(%"%s%s = ATTRIBUTE %s")')
endforeach
self->getProperty, groups=groups
foreach group_name, groups do begin
result += self[group_name]->dump(indent=_indent + ' ')
endforeach
self->getProperty, variables=variables
foreach var_name, variables do begin
result += self[var_name]->dump(indent=_indent + ' ')
endforeach
return, result
end
function mgffncgroup::_overloadPrint
compile_opt strictarr
return, self->dump()
end
function mgffncgroup::_overloadBracketsRightSide, isRange, $
ss1, ss2, ss3, ss4, $
ss5, ss6, ss7, ss8
compile_opt strictarr
on_error, 2
vars = ncdf_varidsinq(self.id)
for v = 0L, n_elements(vars) - 1 do begin
if (vars[v] eq -1L) then break
name = (ncdf_varinq(self.id, vars[v])).name
if (name eq ss1) then begin
new_var = obj_new('MGffNCVariable', identifier=vars[v], parent=self)
self.children->add, new_var
return, new_var
endif
endfor
groups = ncdf_groupsinq(self.id)
for g = 0L, n_elements(groups) - 1L do begin
if (groups[g] eq -1L) then break
name = ncdf_groupname(groups[g])
if (name eq ss1) then begin
new_group = obj_new('MGffNCGroup', identifier=groups[g], parent=self)
self.children->add, new_group
return, new_group
endif
endfor
message, string(ss1, format='(%"%s not found")')
end
pro mgffncgroup::cleanup
compile_opt strictarr
obj_destroy, self.children
end
function mgffncgroup::init, _extra=e
compile_opt strictarr
if (~self->MGffNCBase::init(_extra=e)) then return, 0
self.children = obj_new('IDL_Container')
return, 1
end
pro mgffncgroup__define
compile_opt strictarr
define = { MGffNCGroup, inherits MGffNCBase, $
children: obj_new() $
}
end