From de5fc73d41271a6fd4c1d255b4775da09ac2de22 Mon Sep 17 00:00:00 2001 From: Magnus Jonsson Date: Fri, 23 Jan 2004 00:39:05 +0000 Subject: [PATCH] *** empty log message *** --- include/libtorrent/alert.hpp | 25 +++++++++---------------- src/alert.cpp | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 7b7781f61..5a265a081 100755 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -45,37 +45,31 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include namespace libtorrent { - // TODO: all alerts should have a timestamp class alert { public: enum severity_t { debug, info, warning, critical, fatal, none }; - alert(severity_t severity, const std::string& msg) - : m_msg(msg) - , m_severity(severity) - {} + alert(severity_t severity, const std::string& msg); + virtual ~alert(); - virtual ~alert() {} + // a timestamp is automatically created in the constructor + boost::posix_time::ptime timestamp() const; - const std::string& msg() const - { - return m_msg; - } + const std::string& msg() const; - severity_t severity() const - { - return m_severity; - } + severity_t severity() const; virtual std::auto_ptr clone() const = 0; private: std::string m_msg; severity_t m_severity; + boost::posix_time::ptime m_timestamp; }; class alert_manager @@ -89,8 +83,7 @@ namespace libtorrent { std::auto_ptr get(); void set_severity(alert::severity_t severity); - bool should_post(alert::severity_t severity) const - { return severity >= m_severity; } + bool should_post(alert::severity_t severity) const; private: std::queue m_alerts; diff --git a/src/alert.cpp b/src/alert.cpp index a0e68708c..5c3596957 100755 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -34,6 +34,34 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { + alert::alert(severity_t severity, const std::string& msg) + : m_msg(msg) + , m_severity(severity) + , m_timestamp(boost::posix_time::second_clock::local_time()) + { + } + + alert::~alert() + { + } + + boost::posix_time::ptime alert::timestamp() const + { + return m_timestamp; + } + + const std::string& alert::msg() const + { + return m_msg; + } + + alert::severity_t alert::severity() const + { + return m_severity; + } + + + alert_manager::alert_manager() : m_severity(alert::none) {} @@ -86,6 +114,11 @@ namespace libtorrent { m_severity = severity; } - + + bool alert_manager::should_post(alert::severity_t severity) const + { + return severity >= m_severity; + } + } // namespace libtorrent