ZT/sources/LogMgr.h

122 lines
3.5 KiB
C++

/*******************************************************************************
* *
* Société de Transports de Montréal. *
* 2012 - 2013 *
* *
* Projet Zones Tests *
* *
* *
* *
*******************************************************************************/
/*
Description:
Description du fichier si nécessaire.
*/
/* ************************************************************************** */
/* Revision:
### YYYMMDD JFM
Verision d'origine.
### YYYYMMDD Description du besoin ou du bug
Description du changement.
*/
/* ************************************************************************** */
#ifndef LOGMGR_H
#define LOGMGR_H
#include "ZTData.h"
#include "GlobalDefine.h"
#include <QList>
#include <QDir>
class CLogElement
{
public:
unsigned int mZTLogType;
virtual ~CLogElement();
};
//QDataStream &operator<<(QDataStream &out, const CLogElement &source);
//QDataStream &operator>>(QDataStream &in, CLogElement &dest);
class CZT1LogElement : public CLogElement
{
public:
CZT1LogElement(){mZTLogType=ZT1_LOG_TYPE;}
~CZT1LogElement();
QDateTime mPassageDateTime;
QVector<CZT1LogData*> mZTLogData;
QVector<CZTDetectionData*> mZTDetections;
quint32 mTrainType;
quint32 mNbElements;
quint64 mThreadDataStartTime, mThreadDataEndTime;
QString mLogFileName;
qreal mMeanSpeed;
CZT1FlagsData mFlags;
QString mStationName;
};
//QDataStream &operator<<(QDataStream &out, const CZT1LogElement &source);
//QDataStream &operator>>(QDataStream &in, CZT1LogElement &dest);
class CZT2LogElement : public CLogElement
{
public:
CZT2LogElement(){mZTLogType = ZT2_LOG_TYPE;}
~CZT2LogElement();
QDateTime mPassageDateTime;
QVector<CZT2LogData*> mZTLogData;
QVector<CZTDetectionData*> mZTDetections;
QString mLogFileName;
quint32 mNbElements;
CZT2FlagsData mFlags;
QString mStationName;
};
//QDataStream &operator<<(QDataStream &out, const CZT2LogElement &source);
//QDataStream &operator>>(QDataStream &in, CZT2LogElement &dest);
class CLogMgr
{
public:
CLogMgr();
~CLogMgr();
unsigned int GetLogsCount();
QList<CLogElement*> *GetLogsList();
QFileInfoList GetLogsFilenameList();
// unsigned int CleanLogsOnDisk(qint32 MaxNbLogs, qint64 MaxSize);
unsigned int CleanUpLogs();
unsigned int ParseLogs(bool KeepData = false);
unsigned int ParseNewLog(QString FileName, bool KeepData = false,bool CleanupLogs = true);
CLogElement* LoadLogData(CLogElement * Element);
unsigned int FreeLogData(CLogElement * Element);
unsigned int InitSteppedLogParsing();
bool ParseNextLog();
int DeleteErrorLogs(bool ZT1 = true, bool ZT2 = true);
int SetMaxLogFilesCount(int count);
int KeepAllMPM10Logs(bool keep);
int KeepAllZT1Logs(bool keep);
int KeepAllZT2Logs(bool keep);
private:
QList<CLogElement*> mPassagesList;
unsigned int DestroyLogList();
QFileInfoList mLogsFilelist;
unsigned int mLogsFileIndex;
bool mKeepMPM10Logs, mKeepZT1Logs, mKeepZT2Logs;
int mMaxFileCount;
};
#endif // LOGMGR_H