initial commit before ownership transfer

This commit is contained in:
2016-01-25 17:57:49 +01:00
parent 36056ad002
commit 353bba8342
37 changed files with 7639 additions and 0 deletions

66
code/reader/SensorReader.h Executable file
View File

@@ -0,0 +1,66 @@
#ifndef SENSORREADER_H
#define SENSORREADER_H
#include <fstream>
/** entry for one sensor */
struct SensorEntry {
/** timestamp of occurrence */
uint64_t ts;
/** sensor's number */
int idx;
/** sensor data */
std::string data;
};
/** read sensor data from CSV */
class SensorReader {
private:
std::string file;
std::ifstream fp;
public:
SensorReader(const std::string& file) : file(file) {
rewind();
}
bool hasNext() {
return !fp.bad() && !fp.eof();
}
/** read the next sensor entry */
SensorEntry getNext() {
char delim;
SensorEntry entry;
fp >> entry.ts;
fp >> delim;
fp >> entry.idx;
fp >> delim;
fp >> entry.data;
return entry;
}
/** start again */
void rewind() {
fp.close();
fp.open(file);
assert(fp.is_open());
}
};
#endif // SENSORREADER_H