// rak - Rakshasa's toolbox
// Copyright (C) 2005-2007, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
// This file contains functors that wrap function pointers and member
// function pointers.
//
// 'fn' functors are polymorphic and derives from 'rak::function' and
// thus is less strict about types, this adds the cost of calling a
// virtual function.
//
// 'fun' functors are non-polymorphic and thus cheaper, but requires
// the target object's type in the functor's template arguments.
//
// This should be replaced with TR1 stuff when it becomes widely
// available. At the moment it behaves like std::auto_ptr, so be
// careful when copying.
#ifndef RAK_FUNCTIONAL_FUN_H
#define RAK_FUNCTIONAL_FUN_H
#include <memory>
#include <functional>
namespace rak {
template <typename Result>
class function_base0 {
public:
virtual ~function_base0() {}
virtual Result operator () () = 0;
};
template <typename Result, typename Arg1>
class function_base1 : public std::unary_function<Arg1, Result> {
public:
virtual ~function_base1() {}
virtual Result operator () (Arg1 arg1) = 0;
};
template <typename Result, typename Arg1, typename Arg2>
class function_base2 : public std::binary_function<Arg1, Arg2, Result> {
public:
virtual ~function_base2() {}
virtual Result operator () (Arg1 arg1, Arg2 arg2) = 0;
};
template <typename Result, typename Arg1, typename Arg2, typename Arg3>
class function_base3 {
public:
virtual ~function_base3() {}
virtual Result operator () (Arg1 arg1, Arg2 arg2, Arg3 arg3) = 0;
};
template <typename Result>
class function0 {
public:
typedef Result result_type;
typedef function_base0<Result> base_type;
bool is_valid() const { return m_base.get() != NULL; }
void set(base_type* base) { m_base = std::auto_ptr<base_type>(base); }
base_type* release() { return m_base.release(); }
Result operator () () { return (*m_base)(); }
private:
std::auto_ptr<base_type> m_base;
};
template <typename Result, typename Arg1>
class function1 {
public:
typedef Result result_type;
typedef function_base1<Result, Arg1> base_type;
bool is_valid() const { return m_base.get() != NULL; }
void set(base_type* base) { m_base = std::auto_ptr<base_type>(base); }
base_type* release() { return m_base.release(); }
Result operator () (Arg1 arg1) { return (*m_base)(arg1); }
private:
std::auto_ptr<base_type> m_base;
};
template <typename Result, typename Arg1, typename Arg2>
class function2 {
public:
typedef Result result_type;
typedef function_base2<Result, Arg1, Arg2> base_type;
bool is_valid() const { return m_base.get() != NULL; }
void set(base_type* base) { m_base = std::auto_ptr<base_type>(base); }
base_type* release() { return m_base.release(); }
Result operator () (Arg1 arg1, Arg2 arg2) { return (*m_base)(arg1, arg2); }
private:
std::auto_ptr<base_type> m_base;
};
template <typename Result, typename Arg1, typename Arg2, typename Arg3>
class function3 {
public:
typedef Result result_type;
typedef function_base3<Result, Arg1, Arg2, Arg3> base_type;
bool is_valid() const { return m_base.get() != NULL; }
void set(base_type* base) { m_base = std::auto_ptr<base_type>(base); }
base_type* release() { return m_base.release(); }
Result operator () (Arg1 arg1, Arg2 arg2, Arg3 arg3) { return (*m_base)(arg1, arg2, arg3); }
private:
std::auto_ptr<base_type> m_base;
};
template <typename Result>
class ptr_fn0_t : public function_base0<Result> {
public:
typedef Result (*Func)();
ptr_fn0_t(Func func) : m_func(func) {}
virtual ~ptr_fn0_t() {}
virtual Result operator () () { return m_func(); }
private:
Func m_func;
};
template <typename Result, typename Arg1>
class ptr_fn1_t : public function_base1<Result, Arg1> {
public:
typedef Result (*Func)(Arg1);
ptr_fn1_t(Func func) : m_func(func) {}
virtual ~ptr_fn1_t() {}
virtual Result operator () (Arg1 arg1) { return m_func(arg1); }
private:
Func m_func;
};
template <typename Result, typename Arg1, typename Arg2>
class ptr_fn2_t : public function_base2<Result, Arg1, Arg2> {
public:
typedef Result (*Func)(Arg1, Arg2);
ptr_fn2_t(Func func) : m_func(func) {}
virtual ~ptr_fn2_t() {}
virtual Result operator () (Arg1 arg1, Arg2 arg2) { return m_func(arg1, arg2); }
private:
Func m_func;
};
template <typename Object, typename Result>
class mem_fn0_t : public function_base0<Result> {
public:
typedef Result (Object::*Func)();
mem_fn0_t(Object* object, Func func) : m_object(object), m_func(func) {}
virtual ~mem_fn0_t() {}
virtual Result operator () () { return (m_object->*m_func)(); }
private:
Object* m_object;
Func m_func;
};
template <typename Object, typename Result, typename Arg1>
class mem_fn1_t : public function_base1<Result, Arg1> {
public:
typedef Result (Object::*Func)(Arg1);
mem_fn1_t(Object* object, Func func) : m_object(object), m_func(func) {}
virtual ~mem_fn1_t() {}
virtual Result operator () (Arg1 arg1) { return (m_object->*m_func)(arg1); }
private:
Object* m_object;
Func m_func;
};
template <typename Object, typename Result, typename Arg1, typename Arg2, typename Arg3>
class mem_fn3_t : public function_base3<Result, Arg1, Arg2, Arg3> {
public:
typedef Result (Object::*Func)(Arg1, Arg2, Arg3);
mem_fn3_t(Object* object, Func func) : m_object(object), m_func(func) {}
virtual ~mem_fn3_t() {}
virtual Result operator () (Arg1 arg1, Arg2 arg2, Arg3 arg3) { return (m_object->*m_func)(arg1, arg2, arg3); }
private:
Object* m_object;
Func m_func;
};
template <typename Object, typename Result, typename Arg1, typename Arg2>
class mem_fn2_t : public function_base2<Result, Arg1, Arg2> {
public:
typedef Result (Object::*Func)(Arg1, Arg2);
mem_fn2_t(Object* object, Func func) : m_object(object), m_func(func) {}
virtual ~mem_fn2_t() {}
virtual Result operator () (Arg1 arg1, Arg2 arg2) { return (m_object->*m_func)(arg1, arg2); }
private:
Object* m_object;
Func m_func;
};
template <typename Object, typename Result>
class const_mem_fn0_t : public function_base0<Result> {
public:
没有合适的资源?快使用搜索试试~ 我知道了~
下载工具----一个bt下载工具
需积分: 10 29 下载量 38 浏览量
2008-12-18
10:32:55
上传
评论
收藏 501KB GZ 举报
温馨提示
共234个文件
h:102个
cc:89个
in:10个
一个下载工具一个下载工具一个下载工具一个下载工具一个下载工具一个下载工具一个下载工具一个下载工具
资源推荐
资源详情
资源评论
收起资源包目录
下载工具----一个bt下载工具 (234个子文件)
rtorrent.1 17KB
configure.ac 1KB
Makefile.am 1KB
Makefile.am 778B
Makefile.am 742B
Makefile.am 702B
Makefile.am 517B
Makefile.am 502B
Makefile.am 272B
Makefile.am 269B
Makefile.am 93B
AUTHORS 32B
command_download.cc 26KB
download_list.cc 21KB
manager.cc 17KB
command_ui.cc 16KB
command_events.cc 16KB
command_network.cc 15KB
xmlrpc.cc 15KB
main.cc 14KB
download.cc 13KB
frame.cc 13KB
download_factory.cc 13KB
parse.cc 12KB
utils.cc 11KB
download_list.cc 11KB
dht_manager.cc 10KB
root.cc 10KB
view.cc 10KB
element_file_list.cc 8KB
command_local.cc 8KB
element_peer_list.cc 8KB
element_download_list.cc 8KB
command_file.cc 7KB
command_map.cc 7KB
curl_stack.cc 7KB
parse_commands.cc 7KB
command_slot.cc 7KB
window_file_list.cc 7KB
scgi_task.cc 6KB
command_peer.cc 6KB
element_text.cc 6KB
command_scheduler.cc 6KB
command_helpers.cc 6KB
download_store.cc 5KB
window_peer_list.cc 5KB
socket_fd.cc 5KB
window_download_chunks_seen.cc 5KB
element_transfer_list.cc 5KB
element_chunks_seen.cc 5KB
element_menu.cc 5KB
window_download_transfer_list.cc 5KB
control.cc 5KB
download.cc 5KB
text_element_value.cc 5KB
element_tracker_list.cc 5KB
scgi.cc 5KB
window_tracker_list.cc 5KB
command_tracker.cc 5KB
exec_file.cc 5KB
command_variable.cc 5KB
window_http_queue.cc 4KB
option_parser.cc 4KB
text_element_string.cc 4KB
path_input.cc 4KB
view_manager.cc 4KB
lockfile.cc 4KB
curl_socket.cc 4KB
window_download_statusbar.cc 4KB
poll_manager_select.cc 4KB
window_download_list.cc 4KB
window_text.cc 4KB
signal_handler.cc 4KB
curl_get.cc 3KB
manager.cc 3KB
window_log_complete.cc 3KB
window_log.cc 3KB
scheduler.cc 3KB
canvas.cc 3KB
text_element_list.cc 3KB
window.cc 3KB
text_input.cc 3KB
file_status_cache.cc 3KB
command_scheduler_item.cc 3KB
directory.cc 3KB
element_string_list.cc 3KB
element_log_complete.cc 3KB
command_scheduler.cc 3KB
poll_manager_kqueue.cc 3KB
http_queue.cc 3KB
window_string_list.cc 3KB
poll_manager_epoll.cc 2KB
window_statusbar.cc 2KB
manager.cc 2KB
poll_manager.cc 2KB
log.cc 2KB
input_event.cc 2KB
window_input.cc 2KB
window_title.cc 2KB
bindings.cc 2KB
共 234 条
- 1
- 2
- 3
资源评论
dptangzt
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功