• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdenetwork
  • Sitemap
  • Contact Us
 

kget

bt::Cache

bt::Cache Class Reference

#include <cache.h>

Inheritance diagram for bt::Cache:

Inheritance graph
[legend]

List of all members.


Detailed Description

Author:
Joris Guisson

Manages the temporary data

Interface for a class which manages downloaded data. Subclasses should implement the load and save methods.

Definition at line 47 of file cache.h.


Public Member Functions

 Cache (Torrent &tor, const QString &tmpdir, const QString &datadir)
virtual void changeOutputPath (const QString &outputpath)=0
virtual void changeTmpDir (const QString &ndir)
virtual void close ()=0
virtual void create ()=0
virtual void deleteDataFiles ()=0
virtual Uint64 diskUsage ()=0
virtual void downloadStatusChanged (TorrentFile *, bool)
QString getDataDir () const
virtual QString getOutputPath () const =0
bool hasExistingFiles () const
virtual bool hasMissingFiles (QStringList &sl)=0
virtual void load (Chunk *c)=0
virtual void loadFileMap ()=0
virtual KJob * moveDataFiles (const QMap< TorrentFileInterface *, QString > &files)
virtual KJob * moveDataFiles (const QString &ndir)=0
virtual void moveDataFilesFinished (const QMap< TorrentFileInterface *, QString > &files, KJob *job)
virtual void moveDataFilesFinished (KJob *job)=0
virtual void open ()=0
virtual void preallocateDiskSpace (PreallocationThread *prealloc)=0
virtual bool prep (Chunk *c)=0
virtual void save (Chunk *c)=0
virtual void saveFileMap ()=0
virtual ~Cache ()

Static Public Member Functions

static bool mappedModeAllowed ()
static bool preallocateFully ()
static bool preallocationEnabled ()
static void setPreallocateFully (bool on)
static void setPreallocationEnabled (bool on)
static void setUseFSSpecificPreallocMethod (bool on)
static bool useFSSpecificPreallocMethod ()

Protected Attributes

QString datadir
Uint32 mmap_failures
bool preexisting_files
QString tmpdir
Torrent & tor

Constructor & Destructor Documentation

bt::Cache::Cache ( Torrent &  tor,
const QString &  tmpdir,
const QString &  datadir 
)

Definition at line 32 of file cache.cpp.

bt::Cache::~Cache (  )  [virtual]

Definition at line 45 of file cache.cpp.


Member Function Documentation

virtual void bt::Cache::changeOutputPath ( const QString &  outputpath  )  [pure virtual]

Changes output path.

All data files should already been moved. This just modifies the datadir variable.

Parameters:
outputpath New output path

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

void bt::Cache::changeTmpDir ( const QString &  ndir  )  [virtual]

Changes the tmp dir.

All data files should already been moved. This just modifies the tmpdir variable.

Parameters:
ndir The new tmpdir

Reimplemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

Definition at line 49 of file cache.cpp.

virtual void bt::Cache::close (  )  [pure virtual]

Close the cache file(s).

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::create (  )  [pure virtual]

Create all the data files to store the data.

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::deleteDataFiles (  )  [pure virtual]

Delete all data files, in case of multi file torrents empty directories should also be deleted.

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual Uint64 bt::Cache::diskUsage (  )  [pure virtual]

Get the number of bytes all the files of this torrent are currently using on disk.

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::downloadStatusChanged ( TorrentFile *  ,
bool   
) [inline, virtual]

Does nothing, can be overridden to be alerted of download status changes of a TorrentFile.

Reimplemented in BTCache.

Definition at line 143 of file cache.h.

QString bt::Cache::getDataDir (  )  const [inline]

Get the datadir.

Definition at line 71 of file cache.h.

virtual QString bt::Cache::getOutputPath (  )  const [pure virtual]

Get the actual output path.

Returns:
The output path

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

bool bt::Cache::hasExistingFiles (  )  const [inline]

See if the download has existing files.

Definition at line 152 of file cache.h.

virtual bool bt::Cache::hasMissingFiles ( QStringList &  sl  )  [pure virtual]

Test all files and see if they are not missing.

If so put them in a list

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::load ( Chunk *  c  )  [pure virtual]

Load a chunk into memory.

If something goes wrong, an Error should be thrown.

Parameters:
c The Chunk

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::loadFileMap (  )  [pure virtual]

Load the file map of a torrent.

If it doesn't exist, it needs to be created.

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

bool bt::Cache::mappedModeAllowed (  )  [static]

See if we are allowed to use mmap, when loading chunks.

This will return false if we are close to system limits.

Definition at line 54 of file cache.cpp.

KJob * bt::Cache::moveDataFiles ( const QMap< TorrentFileInterface *, QString > &  files  )  [virtual]

Move some files to a new location.

Parameters:
files Map of files to move and their new location
Returns:
KJob The job doing the move

Reimplemented in bt::MultiFileCache.

Definition at line 62 of file cache.cpp.

virtual KJob* bt::Cache::moveDataFiles ( const QString &  ndir  )  [pure virtual]

Move the data files to a new directory.

Parameters:
ndir The directory
Returns:
The job doing the move

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

void bt::Cache::moveDataFilesFinished ( const QMap< TorrentFileInterface *, QString > &  files,
KJob *  job 
) [virtual]

The job doing moveDataFiles (with the map parameter) has finished.

Parameters:
files The files map with all the moves
job The job doing the move

Reimplemented in bt::MultiFileCache.

Definition at line 68 of file cache.cpp.

virtual void bt::Cache::moveDataFilesFinished ( KJob *  job  )  [pure virtual]

A move of a bunch of data files has finished.

Parameters:
job The job doing the move

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::open (  )  [pure virtual]

Open the cache file(s).

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::preallocateDiskSpace ( PreallocationThread *  prealloc  )  [pure virtual]

Preallocate diskspace for all files.

Parameters:
prealloc The thread doing the preallocation

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

static bool bt::Cache::preallocateFully (  )  [inline, static]

Check if full diskspace preallocation is enabled.

Returns:
true if it is

Definition at line 213 of file cache.h.

static bool bt::Cache::preallocationEnabled (  )  [inline, static]

Check if diskspace preallocation is enabled.

Returns:
true if it is

Definition at line 201 of file cache.h.

virtual bool bt::Cache::prep ( Chunk *  c  )  [pure virtual]

Prepare a chunk for downloading.

Parameters:
c The Chunk
Returns:
true if ok, false otherwise

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::save ( Chunk *  c  )  [pure virtual]

Save a chunk to disk.

If something goes wrong, an Error should be thrown.

Parameters:
c The Chunk

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

virtual void bt::Cache::saveFileMap (  )  [pure virtual]

Save the file map of a torrent.

Implemented in BTCache, bt::MultiFileCache, and bt::SingleFileCache.

static void bt::Cache::setPreallocateFully ( bool  on  )  [inline, static]

Enable or disable full diskspace preallocation.

Parameters:
on 

Definition at line 207 of file cache.h.

static void bt::Cache::setPreallocationEnabled ( bool  on  )  [inline, static]

Enable or disable diskspace preallocation.

Parameters:
on 

Definition at line 195 of file cache.h.

static void bt::Cache::setUseFSSpecificPreallocMethod ( bool  on  )  [inline, static]

Enable or disable FS specific preallocation methods.

Parameters:
on 

Definition at line 219 of file cache.h.

static bool bt::Cache::useFSSpecificPreallocMethod (  )  [inline, static]

Check if FS specific preallocation is enabled.

Returns:
true if it is

Definition at line 225 of file cache.h.


Member Data Documentation

QString bt::Cache::datadir [protected]

Definition at line 52 of file cache.h.

Uint32 bt::Cache::mmap_failures [protected]

Definition at line 54 of file cache.h.

bool bt::Cache::preexisting_files [protected]

Definition at line 53 of file cache.h.

QString bt::Cache::tmpdir [protected]

Definition at line 51 of file cache.h.

Torrent& bt::Cache::tor [protected]

Definition at line 50 of file cache.h.


The documentation for this class was generated from the following files:
  • cache.h
  • cache.cpp

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal