67 inline int min(
int t1,
int t2)
69 return (t1 < t2 ? t1 : t2);
131 BESDEBUG(
"h4",
"hdfistream_sds::_seek_next_arr called with an open sds: "
139 BESDEBUG(
"h4",
"hdfistream_sds::_seek_next_arr inside for-loop with an open sds: "
163 BESDEBUG(
"h4",
"hdfistream_sds::_seek_arr called with an open sds: "
169 const char *nm = name.c_str();
170 if ((index = SDnametoindex(
_file_id, (
char *) nm)) < 0)
174 bool iscoord = SDiscoordvar(
_sds_id);
188 BESDEBUG(
"h4",
"hdfistream_sds::_seek_arr_ref called with an open sds: "
194 if ((index = SDreftoindex(
_file_id, ref)) < 0)
198 bool iscoord = SDiscoordvar(
_sds_id);
288 BESDEBUG(
"h4",
"sds opening file " << filename << endl);
291 if ((
_file_id = SDstart((
char *) filename, DFACC_READ)) < 0)
307 BESDEBUG(
"h4",
"sds file closed: id=" <<
_file_id <<
", this: " <<
this<< endl);
370 vector < int >stride,
bool reduce_rank)
373 if (start.size() != edge.size() || edge.size() != stride.size()
374 || start.size() == 0)
400 hs.
dims = vector < hdf_dim > ();
401 hs.
attrs = vector < hdf_attr > ();
418 if (SDgetinfo(
_sds_id, name, &rank, dim_sizes, &number_type, &nattrs) <
434 for (
int i = 0; i < rank; ++i)
438 int datasize = nelts * DFKNTsize(number_type);
439 data =
new char[datasize];
455 nelts *= dim_sizes[i];
459 int datasize = nelts * DFKNTsize(number_type);
460 data =
new char[datasize];
465 if (SDreaddata(
_sds_id, zero, 0, dim_sizes, data) < 0) {
481 class ce_name_match:
public std::unary_function < array_ce, bool > {
484 ce_name_match(
const string & n):name(n) {
485 }
bool operator() (
const array_ce & a_ce) {
486 return name == a_ce.
name;
498 hd.
attrs = vector < hdf_attr > ();
531 int32 count, number_type, nattrs;
532 if (SDdiminfo(dim_id, name, &count, &number_type, &nattrs) < 0)
552 cerr <<
"dim name: " << name << endl;
553 cerr <<
"slab set: " <<
_slab.
set << endl;
560 vector < array_ce >::iterator ce_iter =
561 find_if(ce.begin(), ce.end(), ce_name_match(
string(name)));
563 cerr <<
"ce name: " << ce_iter->name << endl;
564 cerr <<
"ce set: " << (ce_iter->start != 0 || ce_iter->edge != 0
565 || ce_iter->stride != 0) << endl;
566 cerr <<
"ce start: " << ce_iter->start << endl;
567 cerr <<
"ce edge: " << ce_iter->edge << endl << endl;
570 _slab.
set = ce_iter->start != 0 || ce_iter->edge != 0
571 || ce_iter->stride != 0;
594 int32 junk2, junk3, junk4;
596 if (SDgetinfo(
_sds_id, junk, &junk2, dim_sizes, &junk3, &junk4)
599 count = dim_sizes[0];
606 if (number_type != 0) {
612 if (number_type != DFNT_CHAR) {
615 char *data =
new char[count * DFKNTsize(number_type)];
621 if (SDgetdimscale(dim_id, data) < 0) {
627 void *datastart = (
char *) data +
682 int32 number_type, count;
683 if (SDattrinfo(
id,
_attr_index, name, &number_type, &count) < 0)
688 data =
new char[count * DFKNTsize(number_type)];
702 if (number_type == DFNT_CHAR)
703 count = (int32)
min((
int) count, (int) strlen((
char *) data));
763 if (!
_ok(&has_scale)) {
785 for (
int i = 0; i < (int)
dims.size(); ++i)
786 if (
dims[i].scale.size() != 0) {
789 if (
dims[i].scale.size() !=
dims[i].count)
void _seek_arr_ref(int ref)
bool has_scale(void) const
static const string format
virtual void seek_ref(int ref)
virtual int index(void) const
struct hdfistream_sds::slab _slab
virtual bool eos(void) const
void import(int32 nt, void *data, int nelts)
int32 start[hdfclass::MAXDIMS]
int32 stride[hdfclass::MAXDIMS]
hdfistream_sds(const string filename="")
vector< array_ce > get_map_ce()
virtual bool eo_dim(void) const
virtual void rewind(void)
void _seek_arr(int index)
virtual bool eo_attr(void) const
virtual void seek(int index=0)
virtual bool bos(void) const
virtual void seek_next(void)
static const string long_name
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
void setslab(vector< int >start, vector< int >edge, vector< int >stride, bool reduce_rank=false)
void _seek_next_arr(void)
virtual void open(const char *filename=0)
static const string units
int32 edge[hdfclass::MAXDIMS]
bool _ok(bool *has_scale=0) const
hdfistream_sds & operator>>(hdf_attr &ha)