* 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
+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