mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +00:00
* Replaced View sort code with commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1044 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -147,6 +147,12 @@ template <> struct target_type_id<torrent::FileListIterator*> { static const in
|
||||
|
||||
template <> struct target_type_id<core::Download*, core::Download*> { static const int value = Command::target_download_pair; };
|
||||
|
||||
// Splitting pairs into separate targets.
|
||||
inline bool is_target_pair(const target_type& target) { return target.first >= Command::target_download_pair; }
|
||||
|
||||
inline target_type get_target_left(const target_type& target) { return target_type(target.first - 5, target.second); }
|
||||
inline target_type get_target_right(const target_type& target) { return target_type(target.first - 5, target.third); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+9
-13
@@ -70,19 +70,9 @@ CommandMap::insert(key_type key, const command_map_data_type src) {
|
||||
|
||||
itr = base_type::insert(itr, value_type(key, command_map_data_type(src.m_variable, src.m_flags | flag_dont_delete, src.m_parm, src.m_doc)));
|
||||
|
||||
itr->second.m_target = src.m_target;
|
||||
|
||||
// This _should_ be optimized int just one assignment.
|
||||
switch (itr->second.m_target) {
|
||||
case Command::target_generic: itr->second.m_genericSlot = src.m_genericSlot; break;
|
||||
case Command::target_any: itr->second.m_anySlot = src.m_anySlot; break;
|
||||
case Command::target_download: itr->second.m_downloadSlot = src.m_downloadSlot; break;
|
||||
case Command::target_file: itr->second.m_fileSlot = src.m_fileSlot; break;
|
||||
case Command::target_file_itr: itr->second.m_fileItrSlot = src.m_fileItrSlot; break;
|
||||
case Command::target_peer: itr->second.m_peerSlot = src.m_peerSlot; break;
|
||||
case Command::target_tracker: itr->second.m_trackerSlot = src.m_trackerSlot; break;
|
||||
default: throw torrent::internal_error("CommandMap::insert(...) Invalid target.");
|
||||
}
|
||||
// We can assume all the slots are the same size.
|
||||
itr->second.m_target = src.m_target;
|
||||
itr->second.m_genericSlot = src.m_genericSlot;
|
||||
}
|
||||
|
||||
const CommandMap::mapped_type
|
||||
@@ -119,6 +109,9 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe
|
||||
case Command::target_tracker: return itr->second.m_trackerSlot (itr->second.m_variable, (torrent::Tracker*)target.second, arg);
|
||||
case Command::target_file: return itr->second.m_fileSlot (itr->second.m_variable, (torrent::File*)target.second, arg);
|
||||
case Command::target_file_itr: return itr->second.m_fileItrSlot (itr->second.m_variable, (torrent::FileListIterator*)target.second, arg);
|
||||
|
||||
case Command::target_download_pair: return itr->second.m_downloadPairSlot(itr->second.m_variable, (core::Download*)target.second, (core::Download*)target.third, arg);
|
||||
|
||||
default: throw torrent::internal_error("CommandMap::call_command(...) Invalid target.");
|
||||
}
|
||||
}
|
||||
@@ -146,6 +139,9 @@ CommandMap::call_command(const_iterator itr, const mapped_type& arg, target_type
|
||||
case Command::target_tracker: return itr->second.m_trackerSlot (itr->second.m_variable, (torrent::Tracker*)target.second, arg);
|
||||
case Command::target_file: return itr->second.m_fileSlot (itr->second.m_variable, (torrent::File*)target.second, arg);
|
||||
case Command::target_file_itr: return itr->second.m_fileItrSlot (itr->second.m_variable, (torrent::FileListIterator*)target.second, arg);
|
||||
|
||||
case Command::target_download_pair: return itr->second.m_downloadPairSlot(itr->second.m_variable, (core::Download*)target.second, (core::Download*)target.third, arg);
|
||||
|
||||
default: throw torrent::internal_error("CommandMap::call_command(...) Invalid target.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ struct command_map_data_type {
|
||||
Command::peer_slot m_peerSlot;
|
||||
Command::tracker_slot m_trackerSlot;
|
||||
|
||||
Command::download_slot m_downloadPairSlot;
|
||||
Command::download_pair_slot m_downloadPairSlot;
|
||||
};
|
||||
|
||||
int m_flags;
|
||||
@@ -143,6 +143,11 @@ inline target_type make_target(T target) {
|
||||
return target_type((int)target_type_id<T>::value, target);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline target_type make_target_pair(T target1, T target2) {
|
||||
return target_type((int)target_type_id<T, T>::value, target1, target2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -65,7 +65,7 @@ void parse_command_multiple(target_type target, const char* fi
|
||||
// Make this take care of lists too.
|
||||
parse_command_type parse_command_object(target_type target, const torrent::Object& object);
|
||||
|
||||
inline void parse_command_single(target_type target, const char* first) { parse_command(target, first, first + std::strlen(first)); }
|
||||
inline torrent::Object parse_command_single(target_type target, const char* first) { return parse_command(target, first, first + std::strlen(first)).first; }
|
||||
inline void parse_command_multiple(target_type target, const char* first) { parse_command_multiple(target, first, first + std::strlen(first)); }
|
||||
|
||||
bool parse_command_file(const std::string& path);
|
||||
|
||||
Reference in New Issue
Block a user