aboutsummaryrefslogtreecommitdiff
path: root/src/Reader.hh
blob: 01529ba5e58507d07ef6905141a8319991c11239 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef __READER_HH_
#define __READER_HH_

#include "IO.hh"
#include "FlexArrayTmpl.H"

struct AnnotationInfo{
  int length;
};

class IOdataset;

struct AttributeInfo{
  Long nelements;
  IObase::DataType datatype;
  char name[128];
  IOdataset *dataset;
  int index;
  int read(void *data);
};

class AttribInfoGroup {
  FlexArray<AttributeInfo> attribs;
  IOdataset *dataset;
public:
  AttributeInfo nilattrib;
  AttribInfoGroup(IOdataset *ds);
  ~AttribInfoGroup(){/*puts("Delete AttribInfoGroup");*/ }
  inline void setSize(int sz) {
    attribs.setSize(sz);
  }
  inline int getSize() { 
    return attribs.getSize(); 
  }
  inline AttributeInfo &operator[](int index){
    attribs[index].index=index;
    attribs[index].dataset = dataset;
    return attribs[index];
  }
  AttributeInfo &operator[](char *name);
  AttribInfoGroup(AttribInfoGroup &src);
  AttribInfoGroup &operator=(AttribInfoGroup &src);
};

class IOdataset {
  IObase &file;
  void update();
public:
  int index;
  int rank; // should put in constructor for const
  int dims[5];
  long nbytes;
  long nelements;
  IObase::DataType datatype;
  int typesize;
  

  FlexArray<AnnotationInfo> annotation;
  int nannotations;
  //FlexArray<AttributeInfo> attribute;
  AttribInfoGroup attribute;
  int nattributes;

  IOdataset(IObase &infile,int idx);
  IOdataset(IOdataset &src);
  ~IOdataset(){/*puts("delete IOdataset");*/}
  IOdataset &operator=(IOdataset &src);
  int readAttribute(int index,void *data);
  int attributeIndex(char *name);
  int read(void *data);
}; 

class Reader {
  IObase &file;
public:
  int ndatasets;
  Reader(IObase &infile):file(infile){
    ndatasets=file.nDatasets();
  }
  ~Reader(){/*puts("Delete Reader");*/}
  inline IOdataset operator[](int index){
    IOdataset ds(file,index); // to satisfy GCC 2.95-2
    return ds;
  }
};

#endif