@@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
34
34
#define TORRENT_EXTENSIONS_HPP_INCLUDED
35
35
36
36
#include " libtorrent/units.hpp"
37
+ #include " libtorrent/flags.hpp"
37
38
38
39
// OVERVIEW
39
40
//
@@ -182,6 +183,12 @@ namespace libtorrent {
182
183
struct session_handle ;
183
184
struct peer_connection_handle ;
184
185
186
+ struct feature_flags_tag ;
187
+
188
+ // these are flags that can be returned by implemented_features()
189
+ // indicating which callbacks this plugin is interested in
190
+ using feature_flags_t = flags::bitfield_flag<std::uint8_t , feature_flags_tag>;
191
+
185
192
// this is the base class for a session plugin. One primary feature
186
193
// is that it is notified of all torrents that are added to the session,
187
194
// and can add its own torrent_plugins.
@@ -190,34 +197,29 @@ namespace libtorrent {
190
197
// hidden
191
198
virtual ~plugin () {}
192
199
193
- // these are flags that can be returned by implemented_features()
194
- // indicating which callbacks this plugin is interested in
195
- enum feature_flags_t
196
- {
197
- // include this bit if your plugin needs to alter the order of the
198
- // optimistic unchoke of peers. i.e. have the on_optimistic_unchoke()
199
- // callback be called.
200
- optimistic_unchoke_feature = 1 ,
201
-
202
- // include this bit if your plugin needs to have on_tick() called
203
- tick_feature = 2 ,
204
-
205
- // include this bit if your plugin needs to have on_dht_request()
206
- // called
207
- dht_request_feature = 4 ,
208
-
209
- // include this bit if your plugin needs to have on_alert()
210
- // called
211
- alert_feature = 8 ,
212
- };
200
+ // include this bit if your plugin needs to alter the order of the
201
+ // optimistic unchoke of peers. i.e. have the on_optimistic_unchoke()
202
+ // callback be called.
203
+ static constexpr feature_flags_t optimistic_unchoke_feature = 1_bit;
204
+
205
+ // include this bit if your plugin needs to have on_tick() called
206
+ static constexpr feature_flags_t tick_feature = 2_bit;
207
+
208
+ // include this bit if your plugin needs to have on_dht_request()
209
+ // called
210
+ static constexpr feature_flags_t dht_request_feature = 3_bit;
211
+
212
+ // include this bit if your plugin needs to have on_alert()
213
+ // called
214
+ static constexpr feature_flags_t alert_feature = 4_bit;
213
215
214
216
// This function is expected to return a bitmask indicating which features
215
217
// this plugin implements. Some callbacks on this object may not be called
216
218
// unless the corresponding feature flag is returned here. Note that
217
219
// callbacks may still be called even if the corresponding feature is not
218
220
// specified in the return value here. See feature_flags_t for possible
219
221
// flags to return.
220
- virtual std:: uint32_t implemented_features () { return 0 ; }
222
+ virtual feature_flags_t implemented_features () { return {} ; }
221
223
222
224
// this is called by the session every time a new torrent is added.
223
225
// The ``torrent*`` points to the internal torrent object created
0 commit comments