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

kget

bt::Chunk

bt::Chunk Class Reference

#include <chunk.h>

Inheritance diagram for bt::Chunk:

Inheritance graph
[legend]

List of all members.


Detailed Description

Author:
Joris Guisson

Keep track of a piece of the file

Keeps track of a piece of the file. The Chunk has 3 possible states :

  • MMAPPED : It is memory mapped
  • BUFFERED : It is in a buffer in dynamically allocated memory (because the chunk is located in 2 or more separate files, so we cannot just set a pointer to a region of mmapped memory)
  • ON_DISK : On disk
  • NOT_DOWNLOADED : It hasn't been dowloaded yet, and there is no buffer allocated

Definition at line 44 of file chunk.h.


Public Types

enum  Status { MMAPPED, BUFFERED, ON_DISK, NOT_DOWNLOADED }

Public Member Functions

void allocate ()
bool checkHash (const SHA1Hash &h) const
 Chunk (unsigned int index, Uint32 size)
void clear ()
Uint8 * getData ()
const Uint8 * getData () const
Uint32 getIndex () const
Priority getPriority () const
Uint32 getSize () const
Status getStatus () const
bool isExcluded () const
bool isExcludedForDownloading () const
void ref ()
void setData (Uint8 *d, Status nstatus)
void setExclude (bool yes)
void setPriority (Priority newpriority=NORMAL_PRIORITY)
void setStatus (Status s)
bool taken () const
void unref ()
 ~Chunk ()

Member Enumeration Documentation

enum bt::Chunk::Status

Enumerator:
MMAPPED 
BUFFERED 
ON_DISK 
NOT_DOWNLOADED 

Definition at line 50 of file chunk.h.


Constructor & Destructor Documentation

bt::Chunk::Chunk ( unsigned int  index,
Uint32  size 
)

Definition at line 27 of file chunk.cpp.

bt::Chunk::~Chunk (  ) 

Definition at line 34 of file chunk.cpp.


Member Function Documentation

void bt::Chunk::allocate (  ) 

allocate data if not already done, sets the status to buffered

Definition at line 46 of file chunk.cpp.

bool bt::Chunk::checkHash ( const SHA1Hash &  h  )  const

Check wehter the chunk matches it's hash.

Parameters:
h The hash
Returns:
true if the data matches the hash

Definition at line 68 of file chunk.cpp.

void bt::Chunk::clear (  ) 

Clear the chunk (delete data depending on the mode).

Definition at line 53 of file chunk.cpp.

Uint8 * bt::Chunk::getData (  )  [inline]

Get the data.

Definition at line 142 of file chunk.h.

const Uint8 * bt::Chunk::getData (  )  const [inline]

Get the data.

Definition at line 141 of file chunk.h.

Uint32 bt::Chunk::getIndex (  )  const [inline]

Get the chunk's index.

Definition at line 144 of file chunk.h.

Priority bt::Chunk::getPriority (  )  const [inline]

get chunk priority

Definition at line 151 of file chunk.h.

Uint32 bt::Chunk::getSize (  )  const [inline]

Get the chunk's size.

Definition at line 145 of file chunk.h.

Chunk::Status bt::Chunk::getStatus (  )  const [inline]

Get the chunks status.

Definition at line 131 of file chunk.h.

bool bt::Chunk::isExcluded (  )  const [inline]

Is chunk excluded.

Definition at line 153 of file chunk.h.

bool bt::Chunk::isExcludedForDownloading (  )  const [inline]

Is this a seed only chunk.

Definition at line 158 of file chunk.h.

void bt::Chunk::ref (  )  [inline]

Add one to the reference counter.

Definition at line 147 of file chunk.h.

void bt::Chunk::setData ( Uint8 *  d,
Status  nstatus 
)

Set the data and the new status.

Definition at line 39 of file chunk.cpp.

void bt::Chunk::setExclude ( bool  yes  )  [inline]

In/Exclude chunk.

Definition at line 163 of file chunk.h.

void bt::Chunk::setPriority ( Priority  newpriority = NORMAL_PRIORITY  )  [inline]

set chunk priority

Definition at line 152 of file chunk.h.

void bt::Chunk::setStatus ( Chunk::Status  s  )  [inline]

Set the chunks status.

Parameters:
s 

Definition at line 136 of file chunk.h.

bool bt::Chunk::taken (  )  const [inline]

reference coun > 0

Definition at line 149 of file chunk.h.

void bt::Chunk::unref (  )  [inline]

--reference counter

Definition at line 148 of file chunk.h.


The documentation for this class was generated from the following files:
  • chunk.h
  • chunk.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