@@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
43
43
//
44
44
// By default, only errors are reported. settings_pack::alert_mask can be
45
45
// used to specify which kinds of events should be reported. The alert mask is
46
- // comprised by bits from the category_t enum .
46
+ // a combination of the alert_category_t flags in the alert class .
47
47
//
48
48
// Every alert belongs to one or more category. There is a cost associated with
49
49
// posting alerts. Only alerts that belong to an enabled category are
@@ -63,9 +63,14 @@ POSSIBILITY OF SUCH DAMAGE.
63
63
64
64
#include " libtorrent/time.hpp"
65
65
#include " libtorrent/config.hpp"
66
+ #include " libtorrent/flags.hpp"
66
67
67
68
namespace libtorrent {
68
69
70
+ // hidden
71
+ struct alert_category_tag ;
72
+ using alert_category_t = flags::bitfield_flag<std::uint32_t , alert_category_tag>;
73
+
69
74
// The ``alert`` class is the base class that specific messages are derived from.
70
75
// alert types are not copyable, and cannot be constructed by the client. The
71
76
// pointers returned by libtorrent are short lived (the details are described
@@ -83,112 +88,107 @@ namespace libtorrent {
83
88
enum TORRENT_DEPRECATED severity_t { debug, info, warning, critical, fatal, none };
84
89
#endif
85
90
86
- // these are bits for the alert_mask used by the session. See
87
- // settings_pack::alert_mask.
88
- enum category_t
89
- {
90
- // Enables alerts that report an error. This includes:
91
- //
92
- // * tracker errors
93
- // * tracker warnings
94
- // * file errors
95
- // * resume data failures
96
- // * web seed errors
97
- // * .torrent files errors
98
- // * listen socket errors
99
- // * port mapping errors
100
- error_notification = 0x1 ,
101
-
102
- // Enables alerts when peers send invalid requests, get banned or
103
- // snubbed.
104
- peer_notification = 0x2 ,
105
-
106
- // Enables alerts for port mapping events. For NAT-PMP and UPnP.
107
- port_mapping_notification = 0x4 ,
108
-
109
- // Enables alerts for events related to the storage. File errors and
110
- // synchronization events for moving the storage, renaming files etc.
111
- storage_notification = 0x8 ,
112
-
113
- // Enables all tracker events. Includes announcing to trackers,
114
- // receiving responses, warnings and errors.
115
- tracker_notification = 0x10 ,
116
-
117
- // Low level alerts for when peers are connected and disconnected.
118
- debug_notification = 0x20 ,
119
-
120
- // Enables alerts for when a torrent or the session changes state.
121
- status_notification = 0x40 ,
122
-
123
- // Alerts for when blocks are requested and completed. Also when
124
- // pieces are completed.
125
- progress_notification = 0x80 ,
126
-
127
- // Alerts when a peer is blocked by the ip blocker or port blocker.
128
- ip_block_notification = 0x100 ,
129
-
130
- // Alerts when some limit is reached that might limit the download
131
- // or upload rate.
132
- performance_warning = 0x200 ,
133
-
134
- // Alerts on events in the DHT node. For incoming searches or
135
- // bootstrapping being done etc.
136
- dht_notification = 0x400 ,
137
-
138
- // If you enable these alerts, you will receive a stats_alert
139
- // approximately once every second, for every active torrent.
140
- // These alerts contain all statistics counters for the interval since
141
- // the lasts stats alert.
142
- stats_notification = 0x800 ,
91
+ // Enables alerts that report an error. This includes:
92
+ //
93
+ // * tracker errors
94
+ // * tracker warnings
95
+ // * file errors
96
+ // * resume data failures
97
+ // * web seed errors
98
+ // * .torrent files errors
99
+ // * listen socket errors
100
+ // * port mapping errors
101
+ static constexpr alert_category_t error_notification{0x1 };
102
+
103
+ // Enables alerts when peers send invalid requests, get banned or
104
+ // snubbed.
105
+ static constexpr alert_category_t peer_notification{0x2 };
106
+
107
+ // Enables alerts for port mapping events. For NAT-PMP and UPnP.
108
+ static constexpr alert_category_t port_mapping_notification{0x4 };
109
+
110
+ // Enables alerts for events related to the storage. File errors and
111
+ // synchronization events for moving the storage, renaming files etc.
112
+ static constexpr alert_category_t storage_notification{0x8 };
113
+
114
+ // Enables all tracker events. Includes announcing to trackers,
115
+ // receiving responses, warnings and errors.
116
+ static constexpr alert_category_t tracker_notification{0x10 };
117
+
118
+ // Low level alerts for when peers are connected and disconnected.
119
+ static constexpr alert_category_t debug_notification{0x20 };
120
+
121
+ // Enables alerts for when a torrent or the session changes state.
122
+ static constexpr alert_category_t status_notification{0x40 };
123
+
124
+ // Alerts for when blocks are requested and completed. Also when
125
+ // pieces are completed.
126
+ static constexpr alert_category_t progress_notification{0x80 };
127
+
128
+ // Alerts when a peer is blocked by the ip blocker or port blocker.
129
+ static constexpr alert_category_t ip_block_notification{0x100 };
130
+
131
+ // Alerts when some limit is reached that might limit the download
132
+ // or upload rate.
133
+ static constexpr alert_category_t performance_warning{0x200 };
134
+
135
+ // Alerts on events in the DHT node. For incoming searches or
136
+ // bootstrapping being done etc.
137
+ static constexpr alert_category_t dht_notification{0x400 };
138
+
139
+ // If you enable these alerts, you will receive a stats_alert
140
+ // approximately once every second, for every active torrent.
141
+ // These alerts contain all statistics counters for the interval since
142
+ // the lasts stats alert.
143
+ static constexpr alert_category_t stats_notification{0x800 };
143
144
144
145
#ifndef TORRENT_NO_DEPRECATE
145
- // Alerts on RSS related events, like feeds being updated, feed error
146
- // conditions and successful RSS feed updates. Enabling this category
147
- // will make you receive rss_alert alerts.
148
- rss_notification TORRENT_DEPRECATED_ENUM = 0x1000 ,
146
+ // Alerts on RSS related events, like feeds being updated, feed error
147
+ // conditions and successful RSS feed updates. Enabling this category
148
+ // will make you receive rss_alert alerts.
149
+ static constexpr alert_category_t TORRENT_DEPRECATED_MEMBER rss_notification{ 0x1000 };
149
150
#endif
150
151
151
- // Enables debug logging alerts. These are available unless libtorrent
152
- // was built with logging disabled (``TORRENT_DISABLE_LOGGING``). The
153
- // alerts being posted are log_alert and are session wide.
154
- session_log_notification = 0x2000 ,
152
+ // Enables debug logging alerts. These are available unless libtorrent
153
+ // was built with logging disabled (``TORRENT_DISABLE_LOGGING``). The
154
+ // alerts being posted are log_alert and are session wide.
155
+ static constexpr alert_category_t session_log_notification{ 0x2000 };
155
156
156
- // Enables debug logging alerts for torrents. These are available
157
- // unless libtorrent was built with logging disabled
158
- // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are
159
- // torrent_log_alert and are torrent wide debug events.
160
- torrent_log_notification = 0x4000 ,
157
+ // Enables debug logging alerts for torrents. These are available
158
+ // unless libtorrent was built with logging disabled
159
+ // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are
160
+ // torrent_log_alert and are torrent wide debug events.
161
+ static constexpr alert_category_t torrent_log_notification{ 0x4000 };
161
162
162
- // Enables debug logging alerts for peers. These are available unless
163
- // libtorrent was built with logging disabled
164
- // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are
165
- // peer_log_alert and low-level peer events and messages.
166
- peer_log_notification = 0x8000 ,
163
+ // Enables debug logging alerts for peers. These are available unless
164
+ // libtorrent was built with logging disabled
165
+ // (``TORRENT_DISABLE_LOGGING``). The alerts being posted are
166
+ // peer_log_alert and low-level peer events and messages.
167
+ static constexpr alert_category_t peer_log_notification{ 0x8000 };
167
168
168
- // enables the incoming_request_alert.
169
- incoming_request_notification = 0x10000 ,
169
+ // enables the incoming_request_alert.
170
+ static constexpr alert_category_t incoming_request_notification{ 0x10000 };
170
171
171
- // enables dht_log_alert, debug logging for the DHT
172
- dht_log_notification = 0x20000 ,
172
+ // enables dht_log_alert, debug logging for the DHT
173
+ static constexpr alert_category_t dht_log_notification{ 0x20000 };
173
174
174
- // enable events from pure dht operations not related to torrents
175
- dht_operation_notification = 0x40000 ,
175
+ // enable events from pure dht operations not related to torrents
176
+ static constexpr alert_category_t dht_operation_notification{ 0x40000 };
176
177
177
- // enables port mapping log events. This log is useful
178
- // for debugging the UPnP or NAT-PMP implementation
179
- port_mapping_log_notification = 0x80000 ,
178
+ // enables port mapping log events. This log is useful
179
+ // for debugging the UPnP or NAT-PMP implementation
180
+ static constexpr alert_category_t port_mapping_log_notification{ 0x80000 };
180
181
181
- // enables verbose logging from the piece picker.
182
- picker_log_notification = 0x100000 ,
182
+ // enables verbose logging from the piece picker.
183
+ static constexpr alert_category_t picker_log_notification{ 0x100000 };
183
184
184
- // The full bitmask, representing all available categories.
185
- //
186
- // since the enum is signed, make sure this isn't
187
- // interpreted as -1. For instance, boost.python
188
- // does that and fails when assigning it to an
189
- // unsigned parameter.
190
- all_categories = 0x7fffffff
191
- };
185
+ // The full bitmask, representing all available categories.
186
+ //
187
+ // since the enum is signed, make sure this isn't
188
+ // interpreted as -1. For instance, boost.python
189
+ // does that and fails when assigning it to an
190
+ // unsigned parameter.
191
+ static constexpr alert_category_t all_categories{0x7fffffff };
192
192
193
193
// hidden
194
194
alert ();
@@ -242,7 +242,7 @@ namespace libtorrent {
242
242
virtual std::string message () const = 0;
243
243
244
244
// returns a bitmask specifying which categories this alert belong to.
245
- virtual int category () const = 0;
245
+ virtual alert_category_t category () const = 0;
246
246
247
247
#ifndef TORRENT_NO_DEPRECATE
248
248
0 commit comments