00001 #ifndef Logger_h
00002 #define Logger_h
00003
00004 #include <string>
00005 #include <vector>
00006 #include <fstream>
00007
00008 class State;
00009 typedef boost::shared_ptr<State> StateP;
00010
00016 class Logger
00017 {
00018 public:
00019 typedef struct {
00020 int logLevel;
00021 std::string message;
00022 } Log;
00023
00024 Logger();
00025 ~Logger();
00026
00030 void log(int logLevel, std::string message);
00031
00036 void saveTo(std::string fileName);
00037
00042 void saveTo(bool check = false);
00043
00044 void saveToX(std::string fileName);
00045
00046 void saveToX();
00047
00048 void flushLog();
00049
00054 void setLogFrequency(uint freq);
00055
00056 void registerParameters(StateP state);
00057
00061 bool initialize(StateP state);
00062
00063 bool operate(StateP);
00064
00065 void closeLog()
00066 { logFile_.close(); }
00067
00068 protected:
00069 std::vector<Log> logs_;
00070 int currentLevel_;
00071 uint logFrequency_;
00072 std::string logFileName_;
00073 bool bFileDefined_;
00074 std::ofstream logFile_;
00075 StateP state_;
00076 };
00077 typedef boost::shared_ptr<Logger> LoggerP;
00078
00079 #endif