mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-06 06:09:22 +00:00
* Changed view_filter to use boolean commands instead of custom
functors. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1042 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+24
-8
@@ -102,6 +102,8 @@ public:
|
||||
typedef const torrent::Object (*peer_slot) (Command*, torrent::Peer*, const torrent::Object&);
|
||||
typedef const torrent::Object (*tracker_slot) (Command*, torrent::Tracker*, const torrent::Object&);
|
||||
|
||||
typedef const torrent::Object (*download_pair_slot) (Command*, core::Download*, core::Download*, const torrent::Object&);
|
||||
|
||||
static const int target_generic = 0;
|
||||
static const int target_any = 1;
|
||||
static const int target_download = 2;
|
||||
@@ -110,6 +112,8 @@ public:
|
||||
static const int target_file = 5;
|
||||
static const int target_file_itr = 6;
|
||||
|
||||
static const int target_download_pair = 7;
|
||||
|
||||
Command() {}
|
||||
virtual ~Command() {}
|
||||
|
||||
@@ -118,18 +122,30 @@ protected:
|
||||
void operator = (const Command&);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
template <typename T1 = void, typename T2 = void>
|
||||
struct target_type_id {
|
||||
// Nothing here, so we cause an error.
|
||||
};
|
||||
|
||||
template <> struct target_type_id<Command::generic_slot> { static const int value = Command::target_generic; };
|
||||
template <> struct target_type_id<Command::any_slot> { static const int value = Command::target_any; };
|
||||
template <> struct target_type_id<Command::download_slot> { static const int value = Command::target_download; };
|
||||
template <> struct target_type_id<Command::peer_slot> { static const int value = Command::target_peer; };
|
||||
template <> struct target_type_id<Command::tracker_slot> { static const int value = Command::target_tracker; };
|
||||
template <> struct target_type_id<Command::file_slot> { static const int value = Command::target_file; };
|
||||
template <> struct target_type_id<Command::file_itr_slot> { static const int value = Command::target_file_itr; };
|
||||
template <> struct target_type_id<Command::generic_slot> { static const int value = Command::target_generic; };
|
||||
template <> struct target_type_id<Command::any_slot> { static const int value = Command::target_any; };
|
||||
template <> struct target_type_id<Command::download_slot> { static const int value = Command::target_download; };
|
||||
template <> struct target_type_id<Command::peer_slot> { static const int value = Command::target_peer; };
|
||||
template <> struct target_type_id<Command::tracker_slot> { static const int value = Command::target_tracker; };
|
||||
template <> struct target_type_id<Command::file_slot> { static const int value = Command::target_file; };
|
||||
template <> struct target_type_id<Command::file_itr_slot> { static const int value = Command::target_file_itr; };
|
||||
|
||||
template <> struct target_type_id<Command::download_pair_slot> { static const int value = Command::target_download_pair; };
|
||||
|
||||
template <> struct target_type_id<> { static const int value = Command::target_generic; };
|
||||
template <> struct target_type_id<target_type> { static const int value = Command::target_any; };
|
||||
template <> struct target_type_id<core::Download*> { static const int value = Command::target_download; };
|
||||
template <> struct target_type_id<torrent::Peer*> { static const int value = Command::target_peer; };
|
||||
template <> struct target_type_id<torrent::Tracker*> { static const int value = Command::target_tracker; };
|
||||
template <> struct target_type_id<torrent::File*> { static const int value = Command::target_file; };
|
||||
template <> struct target_type_id<torrent::FileListIterator*> { static const int value = Command::target_file_itr; };
|
||||
|
||||
template <> struct target_type_id<core::Download*, core::Download*> { static const int value = Command::target_download_pair; };
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,8 @@ struct command_map_data_type {
|
||||
Command::file_itr_slot m_fileItrSlot;
|
||||
Command::peer_slot m_peerSlot;
|
||||
Command::tracker_slot m_trackerSlot;
|
||||
|
||||
Command::download_slot m_downloadPairSlot;
|
||||
};
|
||||
|
||||
int m_flags;
|
||||
@@ -108,6 +110,7 @@ public:
|
||||
|
||||
iterator insert(key_type key, Command* variable, int flags, const char* parm, const char* doc);
|
||||
|
||||
// Make this a wrapper call to insert without extra fluff.
|
||||
template <typename T>
|
||||
void insert_type(key_type key, Command* variable, T targetSlot, int flags, const char* parm, const char* doc) {
|
||||
iterator itr = insert(key, variable, flags, parm, doc);
|
||||
@@ -132,12 +135,13 @@ private:
|
||||
};
|
||||
|
||||
inline target_type make_target() { return target_type((int)Command::target_generic, NULL); }
|
||||
inline target_type make_target(core::Download* target) { return target_type((int)Command::target_download, target); }
|
||||
inline target_type make_target(torrent::Peer* target) { return target_type((int)Command::target_peer, target); }
|
||||
inline target_type make_target(torrent::Tracker* target) { return target_type((int)Command::target_tracker, target); }
|
||||
inline target_type make_target(torrent::File* target) { return target_type((int)Command::target_file, target); }
|
||||
inline target_type make_target(torrent::FileListIterator* target) { return target_type((int)Command::target_file_itr, target); }
|
||||
inline target_type make_target(int type, void* target) { return target_type(type, target); }
|
||||
inline target_type make_target(int type, void* target1, void* target2) { return target_type(type, target1, target2); }
|
||||
|
||||
template <typename T>
|
||||
inline target_type make_target(T target) {
|
||||
return target_type((int)target_type_id<T>::value, target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,11 @@ inline void parse_command_multiple(target_type target, const char* fi
|
||||
bool parse_command_file(const std::string& path);
|
||||
const char* parse_command_name(const char* first, const char* last, std::string* dest);
|
||||
|
||||
inline torrent::Object
|
||||
parse_command_single(target_type target, const std::string& cmd) {
|
||||
return parse_command(target, cmd.c_str(), cmd.c_str() + cmd.size()).first;
|
||||
}
|
||||
|
||||
inline void
|
||||
parse_command_single_std(const std::string& cmd) {
|
||||
parse_command(make_target(), cmd.c_str(), cmd.c_str() + cmd.size());
|
||||
|
||||
Reference in New Issue
Block a user