FileReaderVOTable.hh
4.57 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*
* FileReaderVOTable.hh
*
* Created on: Nov 24, 2014
* Author: AKKA
*/
#ifndef FILEREADERVOTABLE_HH_
#define FILEREADERVOTABLE_HH_
#include "FileReaderAbstract.hh"
namespace AMDA {
namespace LocalFileInterface {
/*
* @brief Implementation of the class FileReaderAbstract to load a VOTable file format
*/
class FileReaderVOTable : public FileReaderAbstract
{
public:
static int MaxLineSize;
/*
* @brief Constructor
*/
FileReaderVOTable();
/*
* @brief Destructor
*/
virtual ~FileReaderVOTable();
/*
* @brief Open a VOTable file
*/
virtual bool open(std::string filePath);
/*
* @brief Close the VOTable file
*/
virtual bool close(void);
/*
* @brief Test if a VOTable file is currently opened
*/
virtual bool isOpened(void);
/*
* @brief Get the id of the time param to use. For the VOTable format, it's the first column
*/
virtual std::string getTimeParamId(void);
/*
* @brief Get a param type and a param size in the VOTable file
*/
virtual bool getParamInfo(std::string& paramId, LocalParamType& paramType, int& dim1Size, int& dim2Size);
/*
* @brief Get the index of the nearest record of time (the higher one) in the VOTable file
*/
virtual int getRecordIndex(std::string& timeId, double time);
/*
* @brief Get a param packet from the VOTable file
*/
virtual FileReaderStatus getParamPacketData(std::string& timeId, std::string& paramId,
int recordIndex, double stopTime, LocalParamDataPacket *packet);
/*
* @brief Get an information
*/
virtual bool getInfo(const char* pInfoName, std::vector<double>& res);
private:
class FieldInfo
{
public:
FieldInfo() : _id(), _name(), _xtype(), _size("1"), _type("double"), _ucd(), _unit()
{
}
const std::string& getId() const {
return _id;
}
void setId(const std::string& id) {
_id = id;
}
const std::string& getName() const {
return _name;
}
void setName(const std::string& name) {
_name = name;
}
const std::string& getXtype() const {
return _xtype;
}
void setXtype(const std::string& xtype) {
_xtype = xtype;
}
const std::string& getSize() const {
return _size;
}
void setSize(const std::string& size) {
_size = size;
}
const std::string& getType() const {
return _type;
}
void setType(const std::string& type) {
_type = type;
}
const std::string& getUCD() const {
return _ucd;
}
void setUCD(const std::string& ucd) {
_ucd = ucd;
}
const std::string& getUnit() const {
return _unit;
}
void setUnit(const std::string& unit) {
_unit = unit;
}
private:
std::string _id;
std::string _name;
std::string _xtype;
std::string _size;
std::string _type;
std::string _ucd;
std::string _unit;
};
class ParamInfo
{
public:
ParamInfo() : _groupId(), _name(), _value(), _size("1")
{
}
const std::string& getGroupId() const {
return _groupId;
}
void setGroupId(const std::string& groupId) {
_groupId = groupId;
}
const std::string& getName() const {
return _name;
}
void setName(const std::string& name) {
_name = name;
}
const std::string& getValue() const {
return _value;
}
void setValue(const std::string& value) {
_value = value;
}
const std::string& getSize() const {
return _size;
}
void setSize(const std::string& size) {
_size = size;
}
private:
std::string _groupId;
std::string _name;
std::string _value;
std::string _size;
};
/*
* @brief Retrieve fields and params informations in the VOTable file
*/
void getVOTableInfo(void);
/*
* @brief Retrieve TR line position in the VOTable file where time >= timeStart
*/
int getStartTimePos(int timeColumn, double timeStart);
/*
* @brief Splits a string using the specified delimiter
*/
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
/*
* @brief Get a param packet from the VOTable file
*/
FileReaderStatus getParamPacketData (int timeColumn, int paramColumn, int recordIndex,
double stopTime, LocalParamDataPacket *packet);
/*
* @brief VOTable filename
*/
std::string _votFilePath;
/*
* @brief Ordered list of fields name in the VOTable
*/
std::vector<boost::shared_ptr<FieldInfo>> _fieldsInfo;
/*
* @brief Ordered list of params in the VOTable
*/
std::vector<boost::shared_ptr<ParamInfo>> _paramsInfo;
/*
* @brief Working buffers used to set PacketData
*/
float *_dataFloat;
double *_dataDouble;
short *_dataShort;
int *_dataInt;
void *_data;
};
} /* LocalFileInterface */
} /* AMDA */
#endif /* FILEREADERVOTABLE_HH_ */