| | 54 | |
| | 55 | // Since c++0x isn't out yet... |
| | 56 | template <typename T1, typename T2, typename T3> |
| | 57 | struct rt_triple : private std::pair<T1, T2> { |
| | 58 | typedef std::pair<T1, T2> base_type; |
| | 59 | typedef T3 third_type; |
| | 60 | |
| | 61 | using base_type::first; |
| | 62 | using base_type::second; |
| | 63 | using base_type::first_type; |
| | 64 | using base_type::second_type; |
| | 65 | |
| | 66 | T3 third; |
| | 67 | |
| | 68 | rt_triple() : base_type(), third() {} |
| | 69 | |
| | 70 | rt_triple(const T1& a, const T2& b) : |
| | 71 | base_type(a, b), third() {} |
| | 72 | |
| | 73 | rt_triple(const T1& a, const T2& b, const T3& c) : |
| | 74 | base_type(a, b), third(c) {} |
| | 75 | |
| | 76 | template <typename U1, typename U2> |
| | 77 | rt_triple(const std::pair<U1, U2>& b) : base_type(b), third() {} |
| | 78 | |
| | 79 | template <typename U1, typename U2, typename U3> |
| | 80 | rt_triple(const rt_triple& src) : |
| | 81 | base_type(src.first, src.second), third(src.third) {} |
| | 82 | }; |
| | 97 | typedef const torrent::Object (*generic_slot) (Command*, const torrent::Object&); |
| | 98 | typedef const torrent::Object (*any_slot) (Command*, target_type, const torrent::Object&); |
| | 99 | typedef const torrent::Object (*download_slot) (Command*, core::Download*, const torrent::Object&); |
| | 100 | typedef const torrent::Object (*file_slot) (Command*, torrent::File*, const torrent::Object&); |
| | 101 | typedef const torrent::Object (*file_itr_slot) (Command*, torrent::FileListIterator*, const torrent::Object&); |
| | 102 | typedef const torrent::Object (*peer_slot) (Command*, torrent::Peer*, const torrent::Object&); |
| | 103 | typedef const torrent::Object (*tracker_slot) (Command*, torrent::Tracker*, const torrent::Object&); |
| | 104 | |
| | 105 | static const int target_generic = 0; |
| | 106 | static const int target_any = 1; |
| | 107 | static const int target_download = 2; |
| | 108 | static const int target_peer = 3; |
| | 109 | static const int target_tracker = 4; |
| | 110 | static const int target_file = 5; |
| | 111 | static const int target_file_itr = 6; |
| | 112 | |
| | 121 | template <typename T> |
| | 122 | struct target_type_id { |
| | 123 | // Nothing here, so we cause an error. |
| | 124 | }; |
| | 125 | |
| | 126 | template <> struct target_type_id<Command::generic_slot> { static const int value = Command::target_generic; }; |
| | 127 | template <> struct target_type_id<Command::any_slot> { static const int value = Command::target_any; }; |
| | 128 | template <> struct target_type_id<Command::download_slot> { static const int value = Command::target_download; }; |
| | 129 | template <> struct target_type_id<Command::peer_slot> { static const int value = Command::target_peer; }; |
| | 130 | template <> struct target_type_id<Command::tracker_slot> { static const int value = Command::target_tracker; }; |
| | 131 | template <> struct target_type_id<Command::file_slot> { static const int value = Command::target_file; }; |
| | 132 | template <> struct target_type_id<Command::file_itr_slot> { static const int value = Command::target_file_itr; }; |
| | 133 | |