HashSet< HashType, FileHashType, ChunkSize > Class Template Reference

#include <hash.h>

Inheritance diagram for HashSet< HashType, FileHashType, ChunkSize >:

Inheritance graph
[legend]
Collaboration diagram for HashSet< HashType, FileHashType, ChunkSize >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
class HashSet< HashType, FileHashType, ChunkSize >

Implements concrete HashSet class.

Parameters:
HashType Type of hashes to store in
ChunkSize Optionally set chunk size
FileHashType Optionally set file hash type

Definition at line 344 of file hash.h.


Public Member Functions

 HashSet ()
 Default constructor.
 HashSet (uint32_t chunkSize)
 Initialize with custom chunk size.
 HashSet (Hash< FileHashType > h)
 Construct with existing file hash.
 HashSet (std::istream &i)
 Construct and read from stream.
 ~HashSet ()
 Destructor.
Getters
const HashBasegetFileHash () const
 Get the file hash.
uint32_t getChunkCnt () const
 Number of chunk hashes.
const HashBasegetChunkHash (uint32_t num) const
 Retrieve Nth chunk hash.
uint32_t getChunkSize () const
 Retrieve the size of one chunk.
std::string getFileHashType () const
 RTTI - return string identifying the file hash type.
CGComm::HashTypeId getFileHashTypeId () const
 RTTI - return TypeId of file hash.
std::string getChunkHashType () const
 RTTI - return string identifyin the chunk hash type.
CGComm::HashTypeId getChunkHashTypeId () const
 RTTI - return TypeId of chunk hash.
Setters
void addChunkHash (Hash< HashType > h)
 Add a chunk hash.
void setFileHash (Hash< FileHashType > h)
 Set the file hash, overwriting existing (if any).

Private Attributes

std::vector< Hash< HashType > > m_hashset
 Contains all chunk/chunk/piece hashes. May be empty.
Hash< FileHashType > m_fileHash
 Contains file hash. May be empty.
uint32_t m_chunkSize
 Size of one chunk/chunk/piece.

Constructor & Destructor Documentation

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
HashSet< HashType, FileHashType, ChunkSize >::HashSet  )  [inline]
 

Default constructor.

Definition at line 347 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_chunkSize.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
HashSet< HashType, FileHashType, ChunkSize >::HashSet uint32_t  chunkSize  )  [inline]
 

Initialize with custom chunk size.

Definition at line 350 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_chunkSize.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
HashSet< HashType, FileHashType, ChunkSize >::HashSet Hash< FileHashType >  h  )  [inline]
 

Construct with existing file hash.

Definition at line 353 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_chunkSize, and HashSet< HashType, FileHashType, ChunkSize >::m_fileHash.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
HashSet< HashType, FileHashType, ChunkSize >::HashSet std::istream &  i  )  [inline]
 

Construct and read from stream.

Definition at line 356 of file hash.h.

References HashBase::isEmpty(), logError(), HashSet< HashType, FileHashType, ChunkSize >::m_chunkSize, HashSet< HashType, FileHashType, ChunkSize >::m_fileHash, and HashSet< HashType, FileHashType, ChunkSize >::m_hashset.

Here is the call graph for this function:

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
HashSet< HashType, FileHashType, ChunkSize >::~HashSet  )  [inline]
 

Destructor.

Definition at line 439 of file hash.h.


Member Function Documentation

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
void HashSet< HashType, FileHashType, ChunkSize >::addChunkHash Hash< HashType >  h  )  [inline]
 

Add a chunk hash.

Parameters:
h Chunk hash to add

Definition at line 524 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_hashset.

Referenced by BTHashMaker::getHashSet(), and ED2KHashMaker::getHashSet().

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
uint32_t HashSet< HashType, FileHashType, ChunkSize >::getChunkCnt  )  const [inline, virtual]
 

Number of chunk hashes.

Returns:
Number of chunk hashes

Implements HashSetBase.

Definition at line 460 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_hashset, and Hash< HashType >::size().

Here is the call graph for this function:

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
const HashBase& HashSet< HashType, FileHashType, ChunkSize >::getChunkHash uint32_t  num  )  const [inline, virtual]
 

Retrieve Nth chunk hash.

Parameters:
num Which chunk hash to retrieve.
Returns:
The requested chunk hash.
Exceptions:
std::runtime_error if num > m_hashset.size()

Implements HashSetBase.

Definition at line 470 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_hashset.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
std::string HashSet< HashType, FileHashType, ChunkSize >::getChunkHashType  )  const [inline, virtual]
 

RTTI - return string identifyin the chunk hash type.

Returns:
String representation of chunk hash type

Implements HashSetBase.

Definition at line 502 of file hash.h.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
CGComm::HashTypeId HashSet< HashType, FileHashType, ChunkSize >::getChunkHashTypeId  )  const [inline, virtual]
 

RTTI - return TypeId of chunk hash.

Returns:
Enumeration value indicating chunk hash type

Implements HashSetBase.

Definition at line 509 of file hash.h.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
uint32_t HashSet< HashType, FileHashType, ChunkSize >::getChunkSize  )  const [inline, virtual]
 

Retrieve the size of one chunk.

Returns:
Chunk size

Implements HashSetBase.

Definition at line 479 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_chunkSize.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
const HashBase& HashSet< HashType, FileHashType, ChunkSize >::getFileHash  )  const [inline, virtual]
 

Get the file hash.

Returns:
File Hash - may be empty.

Implements HashSetBase.

Definition at line 451 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_fileHash.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
std::string HashSet< HashType, FileHashType, ChunkSize >::getFileHashType  )  const [inline, virtual]
 

RTTI - return string identifying the file hash type.

Returns:
String representation of file hash type

Implements HashSetBase.

Definition at line 486 of file hash.h.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
CGComm::HashTypeId HashSet< HashType, FileHashType, ChunkSize >::getFileHashTypeId  )  const [inline, virtual]
 

RTTI - return TypeId of file hash.

Returns:
Enumeration value indicating file hash type

Implements HashSetBase.

Definition at line 493 of file hash.h.

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
void HashSet< HashType, FileHashType, ChunkSize >::setFileHash Hash< FileHashType >  h  )  [inline]
 

Set the file hash, overwriting existing (if any).

Parameters:
h New file hash

Definition at line 533 of file hash.h.

References HashSet< HashType, FileHashType, ChunkSize >::m_fileHash.

Referenced by MD4HashMaker::getHashSet(), SHA1HashMaker::getHashSet(), MD5HashMaker::getHashSet(), and ED2KHashMaker::getHashSet().


Member Data Documentation

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
uint32_t HashSet< HashType, FileHashType, ChunkSize >::m_chunkSize [private]
 

Size of one chunk/chunk/piece.

Definition at line 546 of file hash.h.

Referenced by HashSet< HashType, FileHashType, ChunkSize >::getChunkSize(), and HashSet< HashType, FileHashType, ChunkSize >::HashSet().

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
Hash<FileHashType> HashSet< HashType, FileHashType, ChunkSize >::m_fileHash [private]
 

Contains file hash. May be empty.

Definition at line 543 of file hash.h.

Referenced by HashSet< HashType, FileHashType, ChunkSize >::getFileHash(), HashSet< HashType, FileHashType, ChunkSize >::HashSet(), and HashSet< HashType, FileHashType, ChunkSize >::setFileHash().

template<class HashType, class FileHashType = HashType, uint32_t ChunkSize = 0>
std::vector< Hash<HashType> > HashSet< HashType, FileHashType, ChunkSize >::m_hashset [private]
 

Contains all chunk/chunk/piece hashes. May be empty.

Definition at line 540 of file hash.h.

Referenced by HashSet< HashType, FileHashType, ChunkSize >::addChunkHash(), HashSet< HashType, FileHashType, ChunkSize >::getChunkCnt(), HashSet< HashType, FileHashType, ChunkSize >::getChunkHash(), and HashSet< HashType, FileHashType, ChunkSize >::HashSet().


The documentation for this class was generated from the following file: