2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Removed BitfieldManFactory class.
	* src/BitfieldManFactory.cc
	* src/BitfieldManFactory.h
	* src/DefaultPieceStorage.cc
	* src/Makefile.am
	* src/PeerSessionResource.cc
	* src/Piece.cc
	* src/main.cc
	* test/DefaultPieceStorageTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-02-11 08:28:41 +00:00
parent b89e306599
commit 91127ed864
10 changed files with 24 additions and 149 deletions

View File

@ -1,3 +1,15 @@
2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed BitfieldManFactory class.
* src/BitfieldManFactory.cc
* src/BitfieldManFactory.h
* src/DefaultPieceStorage.cc
* src/Makefile.am
* src/PeerSessionResource.cc
* src/Piece.cc
* src/main.cc
* test/DefaultPieceStorageTest.cc
2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed unused methods from BitfieldMan class. Moved Removed unused methods from BitfieldMan class. Moved

View File

@ -1,61 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "BitfieldManFactory.h"
#include "BitfieldMan.h"
namespace aria2 {
BitfieldManFactoryHandle BitfieldManFactory::factory;
BitfieldManFactoryHandle BitfieldManFactory::getFactoryInstance()
{
if(factory.isNull()) {
factory.reset(new BitfieldManFactory());
}
return factory;
}
BitfieldManFactory::BitfieldManFactory() {}
BitfieldManFactory::~BitfieldManFactory() {}
BitfieldMan*
BitfieldManFactory::createBitfieldMan(size_t blockLength, uint64_t totalLength)
{
BitfieldMan* bitfieldMan = new BitfieldMan(blockLength, totalLength);
return bitfieldMan;
}
} // namespace aria2

View File

@ -1,63 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_BITFIELD_MAN_FACTORY_H_
#define _D_BITFIELD_MAN_FACTORY_H_
#include "common.h"
#include "SharedHandle.h"
namespace aria2 {
class Randomizer;
class BitfieldMan;
class BitfieldManFactory {
private:
static SharedHandle<BitfieldManFactory> factory;
BitfieldManFactory();
public:
~BitfieldManFactory();
static SharedHandle<BitfieldManFactory> getFactoryInstance();
BitfieldMan* createBitfieldMan(size_t blockLength, uint64_t totalLength);
};
typedef SharedHandle<BitfieldManFactory> BitfieldManFactoryHandle;
} // namespace aria2
#endif // _D_BITFIELD_MAN_FACTORY_H_

View File

@ -46,7 +46,6 @@
#include "DirectDiskAdaptor.h" #include "DirectDiskAdaptor.h"
#include "MultiDiskAdaptor.h" #include "MultiDiskAdaptor.h"
#include "DiskWriter.h" #include "DiskWriter.h"
#include "BitfieldManFactory.h"
#include "BitfieldMan.h" #include "BitfieldMan.h"
#include "message.h" #include "message.h"
#include "DefaultDiskWriterFactory.h" #include "DefaultDiskWriterFactory.h"
@ -65,9 +64,8 @@ namespace aria2 {
DefaultPieceStorage::DefaultPieceStorage DefaultPieceStorage::DefaultPieceStorage
(const SharedHandle<DownloadContext>& downloadContext, const Option* option): (const SharedHandle<DownloadContext>& downloadContext, const Option* option):
downloadContext(downloadContext), downloadContext(downloadContext),
bitfieldMan(BitfieldManFactory::getFactoryInstance()-> bitfieldMan(new BitfieldMan(downloadContext->getPieceLength(),
createBitfieldMan(downloadContext->getPieceLength(), downloadContext->getTotalLength())),
downloadContext->getTotalLength())),
_diskWriterFactory(new DefaultDiskWriterFactory()), _diskWriterFactory(new DefaultDiskWriterFactory()),
endGamePieceNum(END_GAME_PIECE_NUM), endGamePieceNum(END_GAME_PIECE_NUM),
logger(LogFactory::getInstance()), logger(LogFactory::getInstance()),

View File

@ -60,7 +60,6 @@ SRCS = Socket.h\
SpeedCalc.cc SpeedCalc.h\ SpeedCalc.cc SpeedCalc.h\
PeerStat.h\ PeerStat.h\
BitfieldMan.cc BitfieldMan.h\ BitfieldMan.cc BitfieldMan.h\
BitfieldManFactory.cc BitfieldManFactory.h\
Randomizer.h\ Randomizer.h\
SimpleRandomizer.cc SimpleRandomizer.h\ SimpleRandomizer.cc SimpleRandomizer.h\
HttpResponse.cc HttpResponse.h\ HttpResponse.cc HttpResponse.h\

View File

@ -337,8 +337,7 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
SharedHandle.h HandleRegistry.h FeatureConfig.cc \ SharedHandle.h HandleRegistry.h FeatureConfig.cc \
FeatureConfig.h DownloadEngineFactory.cc \ FeatureConfig.h DownloadEngineFactory.cc \
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \ DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \ BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \
BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \ SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
HttpRequest.cc HttpRequest.h Range.h \ HttpRequest.cc HttpRequest.h Range.h \
AbstractProxyRequestCommand.cc AbstractProxyRequestCommand.h \ AbstractProxyRequestCommand.cc AbstractProxyRequestCommand.h \
@ -782,9 +781,8 @@ am__objects_27 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
base32.$(OBJEXT) LogFactory.$(OBJEXT) TimeA2.$(OBJEXT) \ base32.$(OBJEXT) LogFactory.$(OBJEXT) TimeA2.$(OBJEXT) \
FeatureConfig.$(OBJEXT) DownloadEngineFactory.$(OBJEXT) \ FeatureConfig.$(OBJEXT) DownloadEngineFactory.$(OBJEXT) \
SpeedCalc.$(OBJEXT) BitfieldMan.$(OBJEXT) \ SpeedCalc.$(OBJEXT) BitfieldMan.$(OBJEXT) \
BitfieldManFactory.$(OBJEXT) SimpleRandomizer.$(OBJEXT) \ SimpleRandomizer.$(OBJEXT) HttpResponse.$(OBJEXT) \
HttpResponse.$(OBJEXT) HttpRequest.$(OBJEXT) \ HttpRequest.$(OBJEXT) AbstractProxyRequestCommand.$(OBJEXT) \
AbstractProxyRequestCommand.$(OBJEXT) \
AbstractProxyResponseCommand.$(OBJEXT) Netrc.$(OBJEXT) \ AbstractProxyResponseCommand.$(OBJEXT) Netrc.$(OBJEXT) \
AuthConfig.$(OBJEXT) AbstractAuthResolver.$(OBJEXT) \ AuthConfig.$(OBJEXT) AbstractAuthResolver.$(OBJEXT) \
DefaultAuthResolver.$(OBJEXT) NetrcAuthResolver.$(OBJEXT) \ DefaultAuthResolver.$(OBJEXT) NetrcAuthResolver.$(OBJEXT) \
@ -1087,8 +1085,7 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
SharedHandle.h HandleRegistry.h FeatureConfig.cc \ SharedHandle.h HandleRegistry.h FeatureConfig.cc \
FeatureConfig.h DownloadEngineFactory.cc \ FeatureConfig.h DownloadEngineFactory.cc \
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \ DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \ BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \
BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \ SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
HttpRequest.cc HttpRequest.h Range.h \ HttpRequest.cc HttpRequest.h Range.h \
AbstractProxyRequestCommand.cc AbstractProxyRequestCommand.h \ AbstractProxyRequestCommand.cc AbstractProxyRequestCommand.h \
@ -1306,7 +1303,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BNode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BNode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Base64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Base64.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldMan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldMan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldManFactory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtAllowedFastMessage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtAllowedFastMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtAnnounce.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtAnnounce.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtBitfieldMessage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtBitfieldMessage.Po@am__quote@

View File

@ -37,7 +37,6 @@
#include <cassert> #include <cassert>
#include <algorithm> #include <algorithm>
#include "BitfieldManFactory.h"
#include "BitfieldMan.h" #include "BitfieldMan.h"
#include "A2STR.h" #include "A2STR.h"
#include "BtMessageDispatcher.h" #include "BtMessageDispatcher.h"
@ -52,7 +51,7 @@ PeerSessionResource::PeerSessionResource(size_t pieceLength, uint64_t totalLengt
_chokingRequired(true), _chokingRequired(true),
_optUnchoking(false), _optUnchoking(false),
_snubbing(false), _snubbing(false),
_bitfieldMan(BitfieldManFactory::getFactoryInstance()->createBitfieldMan(pieceLength, totalLength)), _bitfieldMan(new BitfieldMan(pieceLength, totalLength)),
_fastExtensionEnabled(false), _fastExtensionEnabled(false),
_extendedMessagingEnabled(false), _extendedMessagingEnabled(false),
_dhtEnabled(false), _dhtEnabled(false),

View File

@ -34,7 +34,6 @@
/* copyright --> */ /* copyright --> */
#include "Piece.h" #include "Piece.h"
#include "util.h" #include "util.h"
#include "BitfieldManFactory.h"
#include "BitfieldMan.h" #include "BitfieldMan.h"
#include "A2STR.h" #include "A2STR.h"
#include "util.h" #include "util.h"
@ -51,14 +50,13 @@ Piece::Piece():index(0), length(0), _blockLength(BLOCK_LENGTH), bitfield(0)
#endif // ENABLE_MESSAGE_DIGEST #endif // ENABLE_MESSAGE_DIGEST
{} {}
Piece::Piece(size_t index, size_t length, size_t blockLength):index(index), length(length), _blockLength(blockLength) Piece::Piece(size_t index, size_t length, size_t blockLength):
index(index), length(length), _blockLength(blockLength),
bitfield(new BitfieldMan(_blockLength, length))
#ifdef ENABLE_MESSAGE_DIGEST #ifdef ENABLE_MESSAGE_DIGEST
, _nextBegin(0) , _nextBegin(0)
#endif // ENABLE_MESSAGE_DIGEST #endif // ENABLE_MESSAGE_DIGEST
{ {}
bitfield =
BitfieldManFactory::getFactoryInstance()->createBitfieldMan(_blockLength, length);
}
Piece::Piece(const Piece& piece) { Piece::Piece(const Piece& piece) {
index = piece.index; index = piece.index;
@ -206,8 +204,7 @@ void Piece::reconfigure(size_t length)
{ {
delete bitfield; delete bitfield;
this->length = length; this->length = length;
bitfield = bitfield = new BitfieldMan(_blockLength, length);
BitfieldManFactory::getFactoryInstance()->createBitfieldMan(_blockLength, length);
} }
void Piece::setBitfield(const unsigned char* bitfield, size_t len) void Piece::setBitfield(const unsigned char* bitfield, size_t len)

View File

@ -47,7 +47,6 @@
#include "LogFactory.h" #include "LogFactory.h"
#include "Logger.h" #include "Logger.h"
#include "util.h" #include "util.h"
#include "BitfieldManFactory.h"
#include "FeatureConfig.h" #include "FeatureConfig.h"
#include "MultiUrlRequestInfo.h" #include "MultiUrlRequestInfo.h"
#include "SimpleRandomizer.h" #include "SimpleRandomizer.h"

View File

@ -4,7 +4,6 @@
#include "util.h" #include "util.h"
#include "Exception.h" #include "Exception.h"
#include "BitfieldManFactory.h"
#include "Piece.h" #include "Piece.h"
#include "Peer.h" #include "Peer.h"
#include "Option.h" #include "Option.h"