* Added a new Command type based on std::tr1::function aimed at replacing the current ones.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1149 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2010-03-19 09:33:25 +00:00
parent ee5b0819a1
commit 8622100e09
13 changed files with 195 additions and 14 deletions
+16 -11
View File
@@ -6,17 +6,9 @@ SUBDIRS = \
ui \
utils
bin_PROGRAMS = rtorrent
noinst_LIBRARIES = libsub_root.a
rtorrent_LDADD = \
ui/libsub_ui.a \
core/libsub_core.a \
display/libsub_display.a \
input/libsub_input.a \
rpc/libsub_rpc.a \
utils/libsub_utils.a
rtorrent_SOURCES = \
libsub_root_a_SOURCES = \
command_download.cc \
command_dynamic.cc \
command_events.cc \
@@ -34,7 +26,6 @@ rtorrent_SOURCES = \
control.h \
globals.cc \
globals.h \
main.cc \
option_parser.cc \
option_parser.h \
signal_handler.cc \
@@ -46,4 +37,18 @@ rtorrent_SOURCES = \
thread_worker.cc \
thread_worker.h
bin_PROGRAMS = rtorrent
rtorrent_LDADD = \
ui/libsub_ui.a \
core/libsub_core.a \
display/libsub_display.a \
input/libsub_input.a \
rpc/libsub_rpc.a \
utils/libsub_utils.a \
libsub_root.a
rtorrent_SOURCES = \
main.cc
INCLUDES = -I$(srcdir) -I$(top_srcdir)
+5
View File
@@ -157,6 +157,11 @@ apply_d_change_link(int changeType, core::Download* download, const torrent::Obj
return torrent::Object();
}
template <int type> torrent::Object
cmd_d_change_link(core::Download* download, const torrent::Object& rawArgs) {
return apply_d_change_link(type, download, rawArgs);
}
void
apply_d_delete_tied(core::Download* download) {
const std::string& tie = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(download));
+7 -2
View File
@@ -64,6 +64,9 @@ rpc::CommandSlot<torrent::Tracker*>* commandTrackerSlotsItr = commandTr
rpc::CommandSlot<rpc::target_type> commandAnySlots[COMMAND_ANY_SLOTS_SIZE];
rpc::CommandSlot<rpc::target_type>* commandAnySlotsItr = commandAnySlots;
rpc::command_base commandNewSlots[COMMAND_NEW_SLOTS_SIZE];
rpc::command_base* commandNewSlotItr = commandNewSlots;
void initialize_command_object();
void initialize_command_dynamic();
void initialize_command_download();
@@ -99,7 +102,8 @@ initialize_commands() {
commandFileItrSlotsItr > commandFileItrSlots + COMMAND_FILE_ITR_SLOTS_SIZE ||
commandPeerSlotsItr > commandPeerSlots + COMMAND_PEER_SLOTS_SIZE ||
commandTrackerSlotsItr > commandTrackerSlots + COMMAND_TRACKER_SLOTS_SIZE ||
commandAnySlotsItr > commandAnySlots + COMMAND_ANY_SLOTS_SIZE)
commandAnySlotsItr > commandAnySlots + COMMAND_ANY_SLOTS_SIZE ||
commandNewSlotItr > commandNewSlots + COMMAND_NEW_SLOTS_SIZE)
#else
if (commandSlotsItr != commandSlots + COMMAND_SLOTS_SIZE ||
commandVariablesItr != commandVariables + COMMAND_VARIABLES_SIZE ||
@@ -109,7 +113,8 @@ initialize_commands() {
commandFileItrSlotsItr != commandFileItrSlots + COMMAND_FILE_ITR_SLOTS_SIZE ||
commandPeerSlotsItr != commandPeerSlots + COMMAND_PEER_SLOTS_SIZE ||
commandTrackerSlotsItr != commandTrackerSlots + COMMAND_TRACKER_SLOTS_SIZE ||
commandAnySlotsItr != commandAnySlots + COMMAND_ANY_SLOTS_SIZE)
commandAnySlotsItr != commandAnySlots + COMMAND_ANY_SLOTS_SIZE ||
commandNewSlotItr != commandNewSlots + COMMAND_NEW_SLOTS_SIZE)
#endif
throw torrent::internal_error("initialize_commands() static command array size mismatch.");
}
+22
View File
@@ -38,6 +38,7 @@
#define RTORRENT_UTILS_COMMAND_HELPERS_H
#include "rpc/command_slot.h"
#include "rpc/command_new_slot.h"
#include "rpc/command_function.h"
#include "rpc/parse_commands.h"
@@ -58,6 +59,8 @@ namespace rpc {
#define COMMAND_TRACKER_SLOTS_SIZE 15
#define COMMAND_ANY_SLOTS_SIZE 50
#define COMMAND_NEW_SLOTS_SIZE 100
#define ADDING_COMMANDS
extern rpc::CommandSlot<void> commandSlots[COMMAND_SLOTS_SIZE];
@@ -79,6 +82,9 @@ extern rpc::CommandSlot<torrent::Tracker*>* commandTrackerSlotsItr;
extern rpc::CommandSlot<rpc::target_type> commandAnySlots[COMMAND_ANY_SLOTS_SIZE];
extern rpc::CommandSlot<rpc::target_type>* commandAnySlotsItr;
extern rpc::command_base commandNewSlots[COMMAND_NEW_SLOTS_SIZE];
extern rpc::command_base* commandNewSlotItr;
void initialize_commands();
void
@@ -238,4 +244,20 @@ add_variable(key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::stri
commandObjectPtrsItr->set_object(target); \
rpc::commands.insert_type(key, commandObjectPtrsItr++, &rpc::CommandObjectPtr::function, rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, NULL, NULL);
//
// New std::function based command_base helper functions:
//
#define CMD2_A_FUNCTION(key, function, func_type, slot, parm, doc) \
commandNewSlotItr->set_function<rpc::func_type>(slot); \
m_map.insert_type(key, commandNewSlotItr++, &rpc::function, \
rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, NULL, NULL);
#define CMD2_A(key, slot) \
CMD2_A_FUNCTION(key, command_base_call_any, any_function, slot, "i:", "")
#define CMD2_A_STRING(key, slot) \
CMD2_A_FUNCTION(key, command_base_call_any_string, any_string_function, slot, "i:s", "")
#endif
+4
View File
@@ -12,8 +12,12 @@ libsub_rpc_a_SOURCES = \
command_scheduler_item.h \
command_slot.cc \
command_slot.h \
command_new_slot.cc \
command_new_slot.h \
command_variable.cc \
command_variable.h \
command_new_slot.cc \
command_new_slot.h \
exec_file.cc \
exec_file.h \
parse.cc \