changed the alerts to have categories and to be filtered with a bitmask instead of having a severity and be filtered by a severity level.

This commit is contained in:
Arvid Norberg
2008-07-06 12:22:56 +00:00
parent dab1b22982
commit e576babbb8
20 changed files with 1578 additions and 1322 deletions

View File

@@ -67,23 +67,40 @@ namespace libtorrent {
class TORRENT_EXPORT alert
{
public:
// only here for backwards compatibility
enum severity_t { debug, info, warning, critical, fatal, none };
alert(severity_t severity, const std::string& msg);
enum category_t
{
error_notification = 0x1,
peer_notification = 0x2,
port_mapping_notification = 0x4,
storage_notification = 0x8,
tracker_notification = 0x10,
debug_notification = 0x20,
status_notification = 0x40,
progress_notification = 0x80,
ip_block_notification = 0x100,
all_categories = 0xffffffff
};
alert();
virtual ~alert();
// a timestamp is automatically created in the constructor
ptime timestamp() const;
std::string const& msg() const;
virtual char const* what() const = 0;
virtual std::string message() const = 0;
virtual int category() const = 0;
severity_t severity() const;
severity_t severity() const TORRENT_DEPRECATED { return warning; }
virtual std::auto_ptr<alert> clone() const = 0;
private:
std::string m_msg;
severity_t m_severity;
ptime m_timestamp;
};
@@ -97,16 +114,18 @@ namespace libtorrent {
bool pending() const;
std::auto_ptr<alert> get();
void set_severity(alert::severity_t severity);
bool should_post(alert::severity_t severity) const;
template <class T>
bool should_post() const { return m_alert_mask & T::static_category; }
alert const* wait_for_alert(time_duration max_wait);
void set_alert_mask(int m) { m_alert_mask = m; }
private:
std::queue<alert*> m_alerts;
alert::severity_t m_severity;
mutable boost::mutex m_mutex;
boost::condition m_condition;
int m_alert_mask;
};
struct TORRENT_EXPORT unhandled_alert : std::exception

File diff suppressed because it is too large Load Diff

View File

@@ -211,7 +211,7 @@ namespace libtorrent
void check_torrent(boost::shared_ptr<torrent> const& t);
void done_checking(boost::shared_ptr<torrent> const& t);
void set_severity_level(alert::severity_t s);
void set_alert_mask(int m);
std::auto_ptr<alert> pop_alert();
alert const* wait_for_alert(time_duration max_wait);

View File

@@ -317,7 +317,8 @@ namespace libtorrent
void set_max_half_open_connections(int limit);
std::auto_ptr<alert> pop_alert();
void set_severity_level(alert::severity_t s);
void set_severity_level(alert::severity_t s) TORRENT_DEPRECATED;
void set_alert_mask(int m);
alert const* wait_for_alert(time_duration max_wait);