* Use user-modifiable commands instead of slots for the 'on_*' events.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1070 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2008-10-01 14:19:51 +00:00
parent d7c2960d1e
commit 07b9616ef6
13 changed files with 332 additions and 139 deletions
+25 -3
View File
@@ -38,6 +38,7 @@
#define RTORRENT_RPC_COMMAND_FUNCTION_H
#include <string>
#include <vector>
#include <limits>
#include <inttypes.h>
#include <torrent/object.h>
@@ -50,14 +51,35 @@ class CommandFunction : public Command {
public:
CommandFunction(const std::string& cmd = std::string()) : m_command(cmd) {}
const std::string& command() const { return m_command; }
void set_command(const std::string& cmd) { m_command = cmd; }
const std::string& command() const { return m_command; }
void set_command(const std::string& cmd) { m_command = cmd; }
static const torrent::Object call(Command* rawCommand, target_type target, const torrent::Object& args);
private:
// TODO: Replace with a delete-me flag and const char*.
std::string m_command;
std::string m_command;
};
class CommandFunctionList : public Command,
private std::vector<std::pair<std::string, std::string> > {
public:
typedef std::vector<std::pair<std::string, std::string> > base_type;
using Command::value_type;
using base_type::iterator;
using base_type::const_iterator;
using base_type::begin;
using base_type::end;
CommandFunctionList() {}
const_iterator find(const char* key);
void insert(const std::string& key, const std::string& cmd);
void erase(const std::string& key);
static const torrent::Object call(Command* rawCommand, target_type target, const torrent::Object& args);
};
}