diff --git a/ChangeLog b/ChangeLog index 646342d9..2271faec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-02-11 Tatsuhiro Tsujikawa + + 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 Removed unused methods from BitfieldMan class. Moved diff --git a/src/BitfieldManFactory.cc b/src/BitfieldManFactory.cc deleted file mode 100644 index bac17f96..00000000 --- a/src/BitfieldManFactory.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* */ -#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 diff --git a/src/BitfieldManFactory.h b/src/BitfieldManFactory.h deleted file mode 100644 index 317ccccc..00000000 --- a/src/BitfieldManFactory.h +++ /dev/null @@ -1,63 +0,0 @@ -/* */ -#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 factory; - - BitfieldManFactory(); -public: - ~BitfieldManFactory(); - - static SharedHandle getFactoryInstance(); - - BitfieldMan* createBitfieldMan(size_t blockLength, uint64_t totalLength); -}; - -typedef SharedHandle BitfieldManFactoryHandle; - -} // namespace aria2 - -#endif // _D_BITFIELD_MAN_FACTORY_H_ diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index f25a4723..df7d62c7 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -46,7 +46,6 @@ #include "DirectDiskAdaptor.h" #include "MultiDiskAdaptor.h" #include "DiskWriter.h" -#include "BitfieldManFactory.h" #include "BitfieldMan.h" #include "message.h" #include "DefaultDiskWriterFactory.h" @@ -65,9 +64,8 @@ namespace aria2 { DefaultPieceStorage::DefaultPieceStorage (const SharedHandle& downloadContext, const Option* option): downloadContext(downloadContext), - bitfieldMan(BitfieldManFactory::getFactoryInstance()-> - createBitfieldMan(downloadContext->getPieceLength(), - downloadContext->getTotalLength())), + bitfieldMan(new BitfieldMan(downloadContext->getPieceLength(), + downloadContext->getTotalLength())), _diskWriterFactory(new DefaultDiskWriterFactory()), endGamePieceNum(END_GAME_PIECE_NUM), logger(LogFactory::getInstance()), diff --git a/src/Makefile.am b/src/Makefile.am index b49eb8c4..7dca9472 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,7 +60,6 @@ SRCS = Socket.h\ SpeedCalc.cc SpeedCalc.h\ PeerStat.h\ BitfieldMan.cc BitfieldMan.h\ - BitfieldManFactory.cc BitfieldManFactory.h\ Randomizer.h\ SimpleRandomizer.cc SimpleRandomizer.h\ HttpResponse.cc HttpResponse.h\ diff --git a/src/Makefile.in b/src/Makefile.in index 8d1c9301..ef4ea7c3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -337,8 +337,7 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \ SharedHandle.h HandleRegistry.h FeatureConfig.cc \ FeatureConfig.h DownloadEngineFactory.cc \ DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \ - BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \ - BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \ + BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \ SimpleRandomizer.h HttpResponse.cc HttpResponse.h \ HttpRequest.cc HttpRequest.h Range.h \ AbstractProxyRequestCommand.cc AbstractProxyRequestCommand.h \ @@ -782,9 +781,8 @@ am__objects_27 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \ base32.$(OBJEXT) LogFactory.$(OBJEXT) TimeA2.$(OBJEXT) \ FeatureConfig.$(OBJEXT) DownloadEngineFactory.$(OBJEXT) \ SpeedCalc.$(OBJEXT) BitfieldMan.$(OBJEXT) \ - BitfieldManFactory.$(OBJEXT) SimpleRandomizer.$(OBJEXT) \ - HttpResponse.$(OBJEXT) HttpRequest.$(OBJEXT) \ - AbstractProxyRequestCommand.$(OBJEXT) \ + SimpleRandomizer.$(OBJEXT) HttpResponse.$(OBJEXT) \ + HttpRequest.$(OBJEXT) AbstractProxyRequestCommand.$(OBJEXT) \ AbstractProxyResponseCommand.$(OBJEXT) Netrc.$(OBJEXT) \ AuthConfig.$(OBJEXT) AbstractAuthResolver.$(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 \ FeatureConfig.h DownloadEngineFactory.cc \ DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \ - BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \ - BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \ + BitfieldMan.cc BitfieldMan.h Randomizer.h SimpleRandomizer.cc \ SimpleRandomizer.h HttpResponse.cc HttpResponse.h \ HttpRequest.cc HttpRequest.h Range.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)/Base64.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)/BtAnnounce.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtBitfieldMessage.Po@am__quote@ diff --git a/src/PeerSessionResource.cc b/src/PeerSessionResource.cc index 7af48f77..7bbd33b2 100644 --- a/src/PeerSessionResource.cc +++ b/src/PeerSessionResource.cc @@ -37,7 +37,6 @@ #include #include -#include "BitfieldManFactory.h" #include "BitfieldMan.h" #include "A2STR.h" #include "BtMessageDispatcher.h" @@ -52,7 +51,7 @@ PeerSessionResource::PeerSessionResource(size_t pieceLength, uint64_t totalLengt _chokingRequired(true), _optUnchoking(false), _snubbing(false), - _bitfieldMan(BitfieldManFactory::getFactoryInstance()->createBitfieldMan(pieceLength, totalLength)), + _bitfieldMan(new BitfieldMan(pieceLength, totalLength)), _fastExtensionEnabled(false), _extendedMessagingEnabled(false), _dhtEnabled(false), diff --git a/src/Piece.cc b/src/Piece.cc index 79c848da..4c88dd9a 100644 --- a/src/Piece.cc +++ b/src/Piece.cc @@ -34,7 +34,6 @@ /* copyright --> */ #include "Piece.h" #include "util.h" -#include "BitfieldManFactory.h" #include "BitfieldMan.h" #include "A2STR.h" #include "util.h" @@ -51,14 +50,13 @@ Piece::Piece():index(0), length(0), _blockLength(BLOCK_LENGTH), bitfield(0) #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 , _nextBegin(0) #endif // ENABLE_MESSAGE_DIGEST -{ - bitfield = - BitfieldManFactory::getFactoryInstance()->createBitfieldMan(_blockLength, length); -} +{} Piece::Piece(const Piece& piece) { index = piece.index; @@ -206,8 +204,7 @@ void Piece::reconfigure(size_t length) { delete bitfield; this->length = length; - bitfield = - BitfieldManFactory::getFactoryInstance()->createBitfieldMan(_blockLength, length); + bitfield = new BitfieldMan(_blockLength, length); } void Piece::setBitfield(const unsigned char* bitfield, size_t len) diff --git a/src/main.cc b/src/main.cc index bf5efb5a..92239efc 100644 --- a/src/main.cc +++ b/src/main.cc @@ -47,7 +47,6 @@ #include "LogFactory.h" #include "Logger.h" #include "util.h" -#include "BitfieldManFactory.h" #include "FeatureConfig.h" #include "MultiUrlRequestInfo.h" #include "SimpleRandomizer.h" diff --git a/test/DefaultPieceStorageTest.cc b/test/DefaultPieceStorageTest.cc index e17f4f6c..0834d44c 100644 --- a/test/DefaultPieceStorageTest.cc +++ b/test/DefaultPieceStorageTest.cc @@ -4,7 +4,6 @@ #include "util.h" #include "Exception.h" -#include "BitfieldManFactory.h" #include "Piece.h" #include "Peer.h" #include "Option.h"