/*
* xmlgen.hpp
*
* Created on: 2011.11.02.
* Author: TG
*/
#ifndef XMLGEN_HPP_
#define XMLGEN_HPP_
//#define BEEP
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <deque>
#include <ctime>
#include "logger.hpp"
/* countlog XML version */
#define COUNTLOG_VERSION "1.1"
struct XMLentry {
int id;
int timestamp;
bool direction;
inline bool operator <(const XMLentry& a) const {
return (this->timestamp < a.timestamp);
}
};
/* Its expected format:
<countlog version="1.1">
<measurements>
<measure id="1" timestamp="123456789" direction="0"/>
<measure id="2" timestamp="123456456" direction="1"/>
<measure id="3" timestamp="123400487" direction="1"/>
<measure id="4" timestamp="123456789" direction="0"/>
</measurements>
</countlog>
*/
using namespace std;
class XMLgen {
public:
XMLgen();
void add(int id, bool direction);
void add(int id, bool direction, int number); // in case we want to store more logs with same ID
void add(XMLentry entry);
void purge();
void purge(unsigned number);
string generate();
int getEntryNum() {
return storage.size();
}
private:
Logger logger;
deque<XMLentry> storage;
ofstream logfile;
time_t now;
};
#endif /* XMLGEN_HPP_ */