don't shadow static_category in alerts

This commit is contained in:
arvidn 2017-09-16 13:47:04 +02:00 committed by Arvid Norberg
parent 8d6b51d54c
commit 1a8660bca7
3 changed files with 30 additions and 11 deletions

View File

@ -76,8 +76,9 @@ namespace libtorrent {
torrent_alert(aux::stack_allocator& alloc, torrent_handle const& h);
torrent_alert(torrent_alert&&) noexcept = default;
// internal
static const int alert_type = 0;
#ifndef TORRENT_NO_DEPRECATE
static const int TORRENT_DEPRECATED_MEMBER alert_type = 0;
#endif
// returns the message associated with this alert
std::string message() const override;
@ -108,9 +109,10 @@ namespace libtorrent {
tcp::endpoint const& i, peer_id const& pi);
peer_alert(peer_alert&& rhs) noexcept = default;
static const int alert_type = 1;
static constexpr alert_category_t static_category = alert::peer_notification;
alert_category_t category() const override { return static_category; }
#ifndef TORRENT_NO_DEPRECATE
static const int TORRENT_DEPRECATED_MEMBER alert_type = 1;
#endif
std::string message() const override;
// The peer's IP address and port.
@ -134,9 +136,10 @@ namespace libtorrent {
tracker_alert(aux::stack_allocator& alloc, torrent_handle const& h
, tcp::endpoint const& ep, string_view u);
static const int alert_type = 2;
static constexpr alert_category_t static_category = alert::tracker_notification;
alert_category_t category() const override { return static_category; }
#ifndef TORRENT_NO_DEPRECATE
static const int TORRENT_DEPRECATED_MEMBER alert_type = 2;
#endif
std::string message() const override;
// endpoint of the listen interface being announced
@ -496,6 +499,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(scrape_reply_alert, 13)
static constexpr alert_category_t static_category = alert::tracker_notification;
std::string message() const override;
// the data returned in the scrape response. These numbers
@ -552,6 +556,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(tracker_reply_alert, 15)
static constexpr alert_category_t static_category = alert::tracker_notification;
std::string message() const override;
// tells how many peers the tracker returned in this response. This is
@ -571,9 +576,9 @@ namespace libtorrent {
, torrent_handle const& h
, int np);
static constexpr alert_category_t static_category = alert::dht_notification | alert::tracker_notification;
TORRENT_DEFINE_ALERT(dht_reply_alert, 16)
static constexpr alert_category_t static_category = alert::dht_notification | alert::tracker_notification;
std::string message() const override;
int const num_peers;
@ -591,6 +596,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(tracker_announce_alert, 17)
static constexpr alert_category_t static_category = alert::tracker_notification;
std::string message() const override;
// specifies what event was sent to the tracker. It is defined as:
@ -628,6 +634,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(peer_ban_alert, 19)
static constexpr alert_category_t static_category = alert::peer_notification;
std::string message() const override;
};
@ -641,6 +648,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(peer_unsnubbed_alert, 20)
static constexpr alert_category_t static_category = alert::peer_notification;
std::string message() const override;
};
@ -654,6 +662,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(peer_snubbed_alert, 21)
static constexpr alert_category_t static_category = alert::peer_notification;
std::string message() const override;
};
@ -746,6 +755,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(invalid_request_alert, 25)
static constexpr alert_category_t static_category = alert::peer_notification;
std::string message() const override;
// the request we received from the peer
@ -880,6 +890,7 @@ namespace libtorrent {
TORRENT_DEFINE_ALERT(unwanted_block_alert, 32)
static constexpr alert_category_t static_category = alert::peer_notification;
std::string message() const override;
int const block_index;

View File

@ -2500,8 +2500,6 @@ namespace {
}
// this will no longer be necessary in C++17
constexpr alert_category_t peer_alert::static_category;
constexpr alert_category_t tracker_alert::static_category;
constexpr alert_category_t torrent_removed_alert::static_category;
constexpr alert_category_t read_piece_alert::static_category;
constexpr alert_category_t file_completed_alert::static_category;
@ -2511,18 +2509,26 @@ namespace {
constexpr alert_category_t state_changed_alert::static_category;
constexpr alert_category_t tracker_error_alert::static_category;
constexpr alert_category_t tracker_warning_alert::static_category;
constexpr alert_category_t scrape_reply_alert::static_category;
constexpr alert_category_t scrape_failed_alert::static_category;
constexpr alert_category_t tracker_reply_alert::static_category;
constexpr alert_category_t dht_reply_alert::static_category;
constexpr alert_category_t tracker_announce_alert::static_category;
constexpr alert_category_t hash_failed_alert::static_category;
constexpr alert_category_t peer_ban_alert::static_category;
constexpr alert_category_t peer_unsnubbed_alert::static_category;
constexpr alert_category_t peer_snubbed_alert::static_category;
constexpr alert_category_t peer_error_alert::static_category;
constexpr alert_category_t peer_connect_alert::static_category;
constexpr alert_category_t peer_disconnected_alert::static_category;
constexpr alert_category_t invalid_request_alert::static_category;
constexpr alert_category_t torrent_finished_alert::static_category;
constexpr alert_category_t piece_finished_alert::static_category;
constexpr alert_category_t request_dropped_alert::static_category;
constexpr alert_category_t block_timeout_alert::static_category;
constexpr alert_category_t block_finished_alert::static_category;
constexpr alert_category_t block_downloading_alert::static_category;
constexpr alert_category_t unwanted_block_alert::static_category;
constexpr alert_category_t storage_moved_alert::static_category;
constexpr alert_category_t storage_moved_failed_alert::static_category;
constexpr alert_category_t torrent_deleted_alert::static_category;

View File

@ -47,9 +47,11 @@ TORRENT_TEST(alerts_types)
// are abstract
int count_alert_types = 3;
#ifndef TORRENT_NO_DEPRECATE
TEST_EQUAL(torrent_alert::alert_type, 0);
TEST_EQUAL(peer_alert::alert_type, 1);
TEST_EQUAL(tracker_alert::alert_type, 2);
#endif
#define TEST_ALERT_TYPE(name, seq, prio, cat) \
TEST_EQUAL(name::priority, prio); \