Show
Ignore:
Timestamp:
03/13/08 10:28:17 (4 years ago)
Author:
rakshasa
Message:

* Fixed minor bugs in the display of tracker groups. Patch by Josef
Drexler.

* Cleanup of the CommandMap? class.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/rtorrent/src/rpc/command.h

    r970 r1041  
    4040#include <torrent/object.h> 
    4141 
     42namespace core { 
     43  class Download; 
     44} 
     45 
     46namespace torrent { 
     47  class File; 
     48  class FileListIterator; 
     49  class Peer; 
     50  class Tracker; 
     51} 
     52 
    4253namespace rpc { 
     54 
     55// Since c++0x isn't out yet... 
     56template <typename T1, typename T2, typename T3> 
     57struct 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}; 
    4383 
    4484// Since it gets used so many places we might as well put it in the 
    4585// rpc namespace. 
    46 typedef std::pair<int, void*> target_type; 
     86//typedef std::pair<int, void*> target_type; 
     87typedef rt_triple<int, void*, void*> target_type; 
    4788 
    4889class Command { 
     
    5495  typedef torrent::Object::key_type    key_type; 
    5596 
     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 
    56113  Command() {} 
    57114  virtual ~Command() {} 
     
    62119}; 
    63120 
     121template <typename T> 
     122struct target_type_id { 
     123  // Nothing here, so we cause an error. 
     124}; 
     125 
     126template <> struct target_type_id<Command::generic_slot>  { static const int value = Command::target_generic; }; 
     127template <> struct target_type_id<Command::any_slot>      { static const int value = Command::target_any; }; 
     128template <> struct target_type_id<Command::download_slot> { static const int value = Command::target_download; }; 
     129template <> struct target_type_id<Command::peer_slot>     { static const int value = Command::target_peer; }; 
     130template <> struct target_type_id<Command::tracker_slot>  { static const int value = Command::target_tracker; }; 
     131template <> struct target_type_id<Command::file_slot>     { static const int value = Command::target_file; }; 
     132template <> struct target_type_id<Command::file_itr_slot> { static const int value = Command::target_file_itr; }; 
     133 
    64134} 
    65135