#pragma once #include #include #include #include namespace MyTools { // void OpenLogFile(const std::string &FN); // void CloseLogFile(); // void WriteToLog(const std::string &str); // void WriteToLog(const std::string &str, int n); // void WriteToLog(const std::string &str, double d); class Logger { public: virtual void OpenLogFile(const std::string &FN) = 0; virtual void CloseLogFile() = 0; virtual void WriteToLog(const std::string &str) = 0; virtual void WriteToLog(const std::string &str, int n) = 0; virtual void WriteToLog(const std::string &str, double d) = 0; virtual ~Logger() {} }; class FileLoggerSingleton: public Logger { public: static FileLoggerSingleton& getInstance() { static FileLoggerSingleton _instance; return _instance; } void OpenLogFile(const std::string &FN) override; void CloseLogFile() override; void WriteToLog(const std::string &str) override; void WriteToLog(const std::string &str, int n) override; void WriteToLog(const std::string &str, double d) override; private: FileLoggerSingleton() {} FileLoggerSingleton(const FileLoggerSingleton&) = delete; FileLoggerSingleton& operator=(const FileLoggerSingleton&) = delete; FileLoggerSingleton& operator=(FileLoggerSingleton&&) = delete; }; class LoggerSingleton: public Logger { public: static LoggerSingleton& getInstance() { static LoggerSingleton _instance; return _instance; } void OpenLogFile(const std::string &FN) override; void CloseLogFile() override; void WriteToLog(const std::string &str) override; void WriteToLog(const std::string &str, int n) override; void WriteToLog(const std::string &str, double d) override; ~LoggerSingleton(); private: LoggerSingleton() {} LoggerSingleton(const LoggerSingleton&) = delete; LoggerSingleton& operator=(const LoggerSingleton&) = delete; LoggerSingleton& operator=(LoggerSingleton&&) = delete; FileLoggerSingleton& LoadLoggerSingletone(); FileLoggerSingleton *_logger = NULL; std::vector times; }; } // namespace MyTools