/* */ #include "StreamCheckIntegrityEntry.h" #include "RequestGroup.h" #include "DownloadEngine.h" #include "StreamFileAllocationEntry.h" #include "InitiateConnectionCommandFactory.h" #include "CUIDCounter.h" #include "PieceStorage.h" #include "FileAllocationMan.h" #include "DiskAdaptor.h" StreamCheckIntegrityEntry::StreamCheckIntegrityEntry(const RequestHandle& currentRequest, RequestGroup* requestGroup, Command* nextCommand): CheckIntegrityEntry(requestGroup, nextCommand), _currentRequest(currentRequest) {} StreamCheckIntegrityEntry::~StreamCheckIntegrityEntry() {} Commands StreamCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e) { Commands commands; if(_requestGroup->needsFileAllocation()) { FileAllocationEntryHandle entry = new StreamFileAllocationEntry(_currentRequest, _requestGroup, popNextCommand()); e->_fileAllocationMan->pushFileAllocationEntry(entry); } else { if(_nextCommand) { commands.push_back(popNextCommand()); } else { Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1); Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), _currentRequest, _requestGroup, e); commands.push_front(command); copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands)); } } return commands; }