summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-06-20 11:42:33 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-06-20 11:42:33 +0000
commit237f15b491fe98768ec2e04fa9a69ca6411dd99e (patch)
tree5f6dd8ae8249437a516d916e25aa3fc998001085
parentb352b97bc666b51c2fa9cd9e129f407c621b280e (diff)
2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Moved non-trivial functions to *.cc file * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h
-rw-r--r--ChangeLog8
-rw-r--r--src/DownloadContext.cc29
-rw-r--r--src/DownloadContext.h29
-rw-r--r--src/FileEntry.cc37
-rw-r--r--src/FileEntry.h37
5 files changed, 82 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index a5a8f3b9..04f7e4dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
+ Moved non-trivial functions to *.cc file
+ * src/DownloadContext.cc
+ * src/DownloadContext.h
+ * src/FileEntry.cc
+ * src/FileEntry.h
+
+2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
+
Removed unused contants
* src/bittorrent_helper.cc
* src/bittorrent_helper.h
diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc
index 30afcf18..f14dd6e5 100644
--- a/src/DownloadContext.cc
+++ b/src/DownloadContext.cc
@@ -176,4 +176,33 @@ void DownloadContext::releaseRuntimeResource()
}
}
+size_t DownloadContext::getNumPieces() const
+{
+ if(_pieceLength == 0) {
+ return 0;
+ } else {
+ assert(!_fileEntries.empty());
+ return (_fileEntries.back()->getLastOffset()+_pieceLength-1)/_pieceLength;
+ }
+}
+
+uint64_t DownloadContext::getTotalLength() const
+{
+ if(_fileEntries.empty()) {
+ return 0;
+ } else {
+ return _fileEntries.back()->getLastOffset();
+ }
+}
+
+const std::string& DownloadContext::getBasePath() const
+{
+ if(_basePath.empty()) {
+ assert(!_fileEntries.empty());
+ return getFirstFileEntry()->getPath();
+ } else {
+ return _basePath;
+ }
+}
+
} // namespace aria2
diff --git a/src/DownloadContext.h b/src/DownloadContext.h
index e94efd93..e40ea4e2 100644
--- a/src/DownloadContext.h
+++ b/src/DownloadContext.h
@@ -113,14 +113,7 @@ public:
_pieceHashes.assign(first, last);
}
- uint64_t getTotalLength() const
- {
- if(_fileEntries.empty()) {
- return 0;
- } else {
- return _fileEntries.back()->getLastOffset();
- }
- }
+ uint64_t getTotalLength() const;
bool knowsTotalLength() const { return _knowsTotalLength; }
@@ -149,15 +142,7 @@ public:
void setPieceLength(size_t length) { _pieceLength = length; }
- size_t getNumPieces() const
- {
- if(_pieceLength == 0) {
- return 0;
- } else {
- assert(!_fileEntries.empty());
- return (_fileEntries.back()->getLastOffset()+_pieceLength-1)/_pieceLength;
- }
- }
+ size_t getNumPieces() const;
const std::string& getPieceHashAlgo() const { return _pieceHashAlgo; }
@@ -184,15 +169,7 @@ public:
// part of .aria2 control file. If _basePath is set, returns
// _basePath. Otherwise, the first FileEntry's getFilePath() is
// returned.
- const std::string& getBasePath() const
- {
- if(_basePath.empty()) {
- assert(!_fileEntries.empty());
- return getFirstFileEntry()->getPath();
- } else {
- return _basePath;
- }
- }
+ const std::string& getBasePath() const;
void setBasePath(const std::string& basePath) { _basePath = basePath; }
diff --git a/src/FileEntry.cc b/src/FileEntry.cc
index 760ae733..b20389b5 100644
--- a/src/FileEntry.cc
+++ b/src/FileEntry.cc
@@ -378,4 +378,41 @@ bool FileEntry::removeUri(const std::string& uri)
}
}
+std::string FileEntry::getBasename() const
+{
+ return File(_path).getBasename();
+}
+
+std::string FileEntry::getDirname() const
+{
+ return File(_path).getDirname();
+}
+
+size_t FileEntry::setUris(const std::vector<std::string>& uris)
+{
+ _uris.clear();
+ return addUris(uris.begin(), uris.end());
+}
+
+bool FileEntry::addUri(const std::string& uri)
+{
+ if(Request().setUri(uri)) {
+ _uris.push_back(uri);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool FileEntry::insertUri(const std::string& uri, size_t pos)
+{
+ if(Request().setUri(uri)) {
+ pos = std::min(pos, _uris.size());
+ _uris.insert(_uris.begin()+pos, uri);
+ return true;
+ } else {
+ return false;
+ }
+}
+
} // namespace aria2
diff --git a/src/FileEntry.h b/src/FileEntry.h
index 529a7bc2..8e5e2687 100644
--- a/src/FileEntry.h
+++ b/src/FileEntry.h
@@ -84,15 +84,9 @@ public:
FileEntry& operator=(const FileEntry& entry);
- std::string getBasename() const
- {
- return File(_path).getBasename();
- }
+ std::string getBasename() const;
- std::string getDirname() const
- {
- return File(_path).getDirname();
- }
+ std::string getDirname() const;
const std::string& getPath() const { return _path; }
@@ -129,11 +123,7 @@ public:
return _spentUris;
}
- size_t setUris(const std::vector<std::string>& uris)
- {
- _uris.clear();
- return addUris(uris.begin(), uris.end());
- }
+ size_t setUris(const std::vector<std::string>& uris);
template<typename InputIterator>
size_t addUris(InputIterator first, InputIterator last)
@@ -147,26 +137,9 @@ public:
return count;
}
- bool addUri(const std::string& uri)
- {
- if(Request().setUri(uri)) {
- _uris.push_back(uri);
- return true;
- } else {
- return false;
- }
- }
+ bool addUri(const std::string& uri);
- bool insertUri(const std::string& uri, size_t pos)
- {
- if(Request().setUri(uri)) {
- pos = std::min(pos, _uris.size());
- _uris.insert(_uris.begin()+pos, uri);
- return true;
- } else {
- return false;
- }
- }
+ bool insertUri(const std::string& uri, size_t pos);
// Inserts _uris and _spentUris into uris.
void getUris(std::vector<std::string>& uris) const;