rllib  1
rlhistorylogger.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                        rlhistorylogger.h  -  description
00003                              -------------------
00004     begin                : Wed Dec 06 2006
00005     copyright            : (C) 2006 by Rainer Lehrig
00006     email                : lehrig@t-online.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as        *
00013  *   published by the Free Software Foundation                             *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #ifndef _RL_HISTORY_LOGGER_H_
00017 #define _RL_HISTORY_LOGGER_H_
00018 
00019 #include "rldefine.h"
00020 #include "rltime.h"
00021 #include "rlthread.h"
00022 #include <stdio.h>
00023 
00024 typedef struct _rlHistoryLogLine_
00025 {
00026   _rlHistoryLogLine_ *next;
00027   char *line;
00028 }rlHistoryLogLine;
00029 
00035 class rlHistoryLogger
00036 {
00037 public:
00038   rlHistoryLogger(const char *csvName, int maxHoursPerFile, int maxLinesInMemory=100);
00039   virtual ~rlHistoryLogger();
00040   int pushLine(const char *text);
00041   const char *firstLine();
00042   const char *nextLine();
00043   rlMutex mutex;
00044   int debug;
00045 private:
00046   int pushLineToMemory(const char *line);
00047   int pushLineToFile(const char *line);
00048   int openFile();
00049   rlHistoryLogLine *first_line,*current_line;
00050   rlTime time,file_start_time,time_diff;
00051   FILE *fout;
00052   int max_hours_per_file, max_lines_in_memory, current_file;
00053   char *csv_name, *csv_file_name;
00054 };
00055 #endif