Skip to content

Commit

Permalink
2010-11-14 Tatsuhiro Tsujikawa <[email protected]>
Browse files Browse the repository at this point in the history
	Added .cc file for classes/structs that only provided by header
	file. Defined non-POD classes' ctor, dtor in .cc file.  Moved
	implementation code in header file to .cc file for major
	classes/strucsts.
  • Loading branch information
tatsuhiro-t committed Nov 14, 2010
1 parent 93e5dbe commit 1372ac5
Show file tree
Hide file tree
Showing 272 changed files with 5,422 additions and 2,487 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2010-11-14 Tatsuhiro Tsujikawa <[email protected]>

Added .cc file for classes/structs that only provided by header
file. Defined non-POD classes' ctor, dtor in .cc file. Moved
implementation code in header file to .cc file for major
classes/strucsts.

2010-11-12 Tatsuhiro Tsujikawa <[email protected]>

Removed SharedHandle::isNull(). Instead we added operator* and
Expand Down
39 changes: 34 additions & 5 deletions src/AbstractCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
#include "CreateRequestCommand.h"
#include "InitiateConnectionCommandFactory.h"
#include "SleepCommand.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
#include "StreamCheckIntegrityEntry.h"
#include "PieceStorage.h"
#include "Socket.h"
Expand All @@ -66,9 +63,11 @@
#include "DownloadContext.h"
#include "wallclock.h"
#include "NameResolver.h"
#include "ServerStatMan.h"
#include "FileAllocationEntry.h"
#include "uri.h"
#include "FileEntry.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
#endif // ENABLE_ASYNC_DNS
#ifdef ENABLE_MESSAGE_DIGEST
# include "ChecksumCheckIntegrityEntry.h"
#endif // ENABLE_MESSAGE_DIGEST
Expand Down Expand Up @@ -861,4 +860,34 @@ size_t AbstractCommand::calculateMinSplitSize() const
}
}

void AbstractCommand::setRequest(const SharedHandle<Request>& request)
{
req_ = request;
}

void AbstractCommand::setFileEntry(const SharedHandle<FileEntry>& fileEntry)
{
fileEntry_ = fileEntry;
}

void AbstractCommand::setSocket(const SharedHandle<SocketCore>& s)
{
socket_ = s;
}

const SharedHandle<DownloadContext>& AbstractCommand::getDownloadContext() const
{
return requestGroup_->getDownloadContext();
}

const SharedHandle<SegmentMan>& AbstractCommand::getSegmentMan() const
{
return requestGroup_->getSegmentMan();
}

const SharedHandle<PieceStorage>& AbstractCommand::getPieceStorage() const
{
return requestGroup_->getPieceStorage();
}

} // namespace aria2
45 changes: 16 additions & 29 deletions src/AbstractCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,24 @@
#define D_ABSTRACT_COMMAND_H

#include "Command.h"

#include <vector>
#include <string>

#include "SharedHandle.h"
#include "TimerA2.h"
#include "FileEntry.h"
#include "RequestGroup.h"

namespace aria2 {

class FileEntry;
class RequestGroup;
class CheckIntegrityEntry;
class DownloadContext;
class SegmentMan;
class PieceStorage;
class Request;
class DownloadEngine;
class Segment;
class Exception;
class SocketCore;
class Option;
#ifdef ENABLE_ASYNC_DNS
Expand Down Expand Up @@ -98,20 +105,14 @@ class AbstractCommand : public Command {
return req_;
}

void setRequest(const SharedHandle<Request>& request)
{
req_ = request;
}
void setRequest(const SharedHandle<Request>& request);

const SharedHandle<FileEntry>& getFileEntry() const
{
return fileEntry_;
}

void setFileEntry(const SharedHandle<FileEntry>& fileEntry)
{
fileEntry_ = fileEntry;
}
void setFileEntry(const SharedHandle<FileEntry>& fileEntry);

DownloadEngine* getDownloadEngine() const
{
Expand All @@ -123,10 +124,7 @@ class AbstractCommand : public Command {
return socket_;
}

void setSocket(const SharedHandle<SocketCore>& s)
{
socket_ = s;
}
void setSocket(const SharedHandle<SocketCore>& s);

void createSocket();

Expand Down Expand Up @@ -213,20 +211,9 @@ class AbstractCommand : public Command {

const SharedHandle<Option>& getOption() const;

const SharedHandle<DownloadContext>& getDownloadContext() const
{
return requestGroup_->getDownloadContext();
}

const SharedHandle<SegmentMan>& getSegmentMan() const
{
return requestGroup_->getSegmentMan();
}

const SharedHandle<PieceStorage>& getPieceStorage() const
{
return requestGroup_->getPieceStorage();
}
const SharedHandle<DownloadContext>& getDownloadContext() const;
const SharedHandle<SegmentMan>& getSegmentMan() const;
const SharedHandle<PieceStorage>& getPieceStorage() const;

Timer& getCheckPoint()
{
Expand Down
7 changes: 0 additions & 7 deletions src/AbstractProxyRequestCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,7 @@
#include "Option.h"
#include "prefs.h"
#include "Socket.h"
#include "CookieStorage.h"
#include "AuthConfigFactory.h"
#include "AuthConfig.h"
#include "DownloadContext.h"
#include "RequestGroupMan.h"
#include "ServerStatMan.h"
#include "FileAllocationEntry.h"
#include "CheckIntegrityEntry.h"

namespace aria2 {

Expand Down
4 changes: 0 additions & 4 deletions src/AbstractProxyResponseCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
#include "message.h"
#include "HttpHeader.h"
#include "DownloadContext.h"
#include "RequestGroupMan.h"
#include "FileAllocationEntry.h"
#include "CheckIntegrityEntry.h"
#include "ServerStatMan.h"

namespace aria2 {

Expand Down
4 changes: 2 additions & 2 deletions src/AbstractSingleDiskAdaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
#include "AbstractSingleDiskAdaptor.h"
#include "File.h"
#include "AdaptiveFileAllocationIterator.h"
#include "DiskWriter.h"
#include "FileEntry.h"
#ifdef HAVE_SOME_FALLOCATE
# include "FallocFileAllocationIterator.h"
#endif // HAVE_SOME_FALLOCATE
#include "DiskWriter.h"
#include "FileEntry.h"

namespace aria2 {

Expand Down
4 changes: 0 additions & 4 deletions src/ActivePeerConnectionCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
#include "bittorrent_helper.h"
#include "wallclock.h"
#include "util.h"
#include "RequestGroupMan.h"
#include "FileAllocationEntry.h"
#include "CheckIntegrityEntry.h"
#include "ServerStatMan.h"

namespace aria2 {

Expand Down
20 changes: 17 additions & 3 deletions src/AdaptiveFileAllocationIterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
/* copyright --> */
#include "AdaptiveFileAllocationIterator.h"
#include "BinaryStream.h"
#ifdef HAVE_FALLOCATE
# include "FallocFileAllocationIterator.h"
#endif // HAVE_FALLOCATE
#include "SingleFileAllocationIterator.h"
#include "RecoverableException.h"
#include "LogFactory.h"
#include "Logger.h"
#ifdef HAVE_FALLOCATE
# include "FallocFileAllocationIterator.h"
#endif // HAVE_FALLOCATE

namespace aria2 {

Expand Down Expand Up @@ -99,4 +99,18 @@ bool AdaptiveFileAllocationIterator::finished()
}
}

off_t AdaptiveFileAllocationIterator::getCurrentLength()
{
if(!allocator_) {
return offset_;
} else {
return allocator_->getCurrentLength();
}
}

uint64_t AdaptiveFileAllocationIterator::getTotalLength()
{
return totalLength_;
}

} // namespace aria2
14 changes: 2 additions & 12 deletions src/AdaptiveFileAllocationIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,9 @@ class AdaptiveFileAllocationIterator:public FileAllocationIterator

virtual bool finished();

virtual off_t getCurrentLength()
{
if(!allocator_) {
return offset_;
} else {
return allocator_->getCurrentLength();
}
}
virtual off_t getCurrentLength();

virtual uint64_t getTotalLength()
{
return totalLength_;
}
virtual uint64_t getTotalLength();
};

} // namespace aria2
Expand Down
82 changes: 82 additions & 0 deletions src/AlphaNumberDecorator.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2010 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 "AlphaNumberDecorator.h"

#include <algorithm>

namespace aria2 {

namespace {
std::string widen(const std::string& s, size_t width, char zeroChar)
{
std::string t = s;
std::string zero(1, zeroChar);
while(t.size() < width) {
t.insert(0, zero);
}
return t;
}
} // namespace

AlphaNumberDecorator::AlphaNumberDecorator(size_t width, bool uppercase)
: width_(width),
zero_(uppercase?'A':'a')
{}

AlphaNumberDecorator::~AlphaNumberDecorator() {}

std::string AlphaNumberDecorator::decorate(unsigned int number)
{
if(number == 0) {
return widen(std::string(1, zero_), width_, zero_);
}

int base = 26;
char u[14]; // because if unsigned int is 64bit, which is the
// biggest integer for the time being and number is
// UINT64_MAX, you get "HLHXCZMXSYUMQP"
size_t index = 0;
do {
unsigned int quot = number/base;
unsigned int rem = number%base;
u[index++] = zero_+rem;
number = quot;
} while(number);
std::reverse(&u[0], &u[index]);

return widen(std::string(&u[0], &u[index]), width_, zero_);
}

} // namespace aria2
Loading

0 comments on commit 1372ac5

Please sign in to comment.