-
Notifications
You must be signed in to change notification settings - Fork 0
/
omxmatrix.h
86 lines (65 loc) · 2.01 KB
/
omxmatrix.h
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
/* omxmatrix.h
*
* OMX/HDF5 Matrix helper routines
*
* @author Billy Charlton, PSRC
* @author Ben Stabler, RSG
*/
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <hdf5.h>
#include <hdf5_hl.h>
using namespace std;
//--------------------------------------------------------------------
#ifndef OMXMATRIX_H
#define OMXMATRIX_H
#define MODE_READWRITE 0
#define MODE_CREATE 1
#define MAX_TABLES 500
bool isOMX(char*);
class OMXMatrix {
public:
OMXMatrix();
virtual ~OMXMatrix();
void openFile(string fileName);
void closeFile();
//Read/Open operations
int getRows();
int getCols();
int getTables();
void getRow(string table, int row, void *rowptr); // throws InvalidOperationException, MatrixReadException
void getCol(string table, int col, void *colptr); // throws InvalidOperationException, MatrixReadException
string getTableName(int table);
//Write/Create operations
void createFile(int tables, int rows, int cols, vector<string> &matNames, string fileName);
void writeRow(string table, int row, double* rowptr);
//Nested exception classes
class FileOpenException { };
class MatrixReadException { };
class InvalidOperationException { };
class OutOfMemoryException {};
class NoSuchTableException {};
//--------------------------------------------------------------------
//Data
hid_t _h5file;
int _nRows;
int _nCols;
int _nTables;
int _mode;
bool _fileOpen;
string _tableName[MAX_TABLES+1];
map<string,int> _tableLookup;
map<string,hid_t> _dataset;
map<string,hid_t> _dataspace;
private:
hid_t _memspace;
//Methods
void readTableNames();
void printErrorCode(int error);
void init_tables (vector<string> &tableNames);
hid_t openDataset(string table); // throws InvalidOperationException
};
#endif /* OMXMATRIX_H */