From ef2b52f06bec2d68e878f76f5874f44e91eff2e1 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 9 Jul 2014 21:25:02 +0000 Subject: [PATCH] added missing files --- examples/session_view.hpp | 60 +++++++++++++++++++++++++++++++ examples/torrent_view.hpp | 76 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 examples/session_view.hpp create mode 100644 examples/torrent_view.hpp diff --git a/examples/session_view.hpp b/examples/session_view.hpp new file mode 100644 index 000000000..a6a7d83c9 --- /dev/null +++ b/examples/session_view.hpp @@ -0,0 +1,60 @@ +#ifndef SESSION_VIEW_HPP_ +#define SESSION_VIEW_HPP_ + +#include "libtorrent/session.hpp" + +namespace lt = libtorrent; + +struct session_view +{ + session_view(); + + void set_pos(int pos); + + int pos() const; + + int height() const; + + void render(); + + void update_counters(std::vector& stats_counters + , boost::uint64_t t); + +private: + + int m_position; + + // there are two sets of counters. the current one and the last one. This + // is used to calculate rates + std::vector m_cnt[2]; + + // the timestamps of the counters in m_cnt[0] and m_cnt[1] + // respectively. The timestamps are microseconds since session start + boost::uint64_t m_timestamp[2]; + + int m_queued_bytes_idx; + int m_wasted_bytes_idx; + int m_failed_bytes_idx; + int m_num_peers_idx; + int m_recv_payload_idx; + int m_sent_payload_idx; + int m_unchoked_idx; + int m_unchoke_slots_idx; + int m_limiter_up_queue_idx; + int m_limiter_down_queue_idx; + int m_limiter_up_bytes_idx; + int m_limiter_down_bytes_idx; + int m_queued_writes_idx; + int m_queued_reads_idx; + int m_writes_cache_idx; + int m_reads_cache_idx; + int m_pinned_idx; + int m_num_blocks_read_idx; + int m_cache_hit_idx; + int m_blocks_in_use_idx; + int m_blocks_written_idx; + int m_write_ops_idx; +}; + +#endif + diff --git a/examples/torrent_view.hpp b/examples/torrent_view.hpp new file mode 100644 index 000000000..258b919f8 --- /dev/null +++ b/examples/torrent_view.hpp @@ -0,0 +1,76 @@ +#ifndef TORRENT_VIEW_HPP_ +#define TORRENT_VIEW_HPP_ + +#include + +#include "libtorrent/torrent_handle.hpp" + +namespace lt = libtorrent; + +struct torrent_view +{ + torrent_view(); + + void set_size(int width, int height); + + enum { + torrents_all, + torrents_downloading, + torrents_not_paused, + torrents_seeding, + torrents_queued, + torrents_stopped, + torrents_checking, + torrents_loaded, + + torrents_max + }; + + int filter() const; + + void set_filter(int filter); + + // returns the lt::torrent_status of the currently selected torrent. + lt::torrent_status const& get_active_torrent() const; + lt::torrent_handle get_active_handle() const; + + void update_torrents(std::vector const& st); + + int height() const; + + void arrow_up(); + void arrow_down(); + + void render(); + +private: + + void print_tabs(); + + void print_headers(); + + void print_torrent(lt::torrent_status const& s, bool selected); + + bool show_torrent(lt::torrent_status const& st); + + // refresh all pointers in m_filtered_handles. This must be done when + // inserting or removing elements from m_all_handles, since pointers may + // be invalidated or when a torrent changes status to either become + // visible or filtered + void update_filtered_torrents(); + + // all torrents + boost::unordered_set m_all_handles; + + // pointers into m_all_handles of the remaining torrents after filtering + std::vector m_filtered_handles; + + mutable int m_active_torrent; // index into m_filtered_handles + int m_scroll_position; + int m_torrent_filter; + int m_width; + int m_height; +}; + +#endif // TORRENT_VIEW_HPP_ +