diff options
Diffstat (limited to 'src/DownloadContext.cc')
| -rw-r--r-- | src/DownloadContext.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc index 1f6eb26f..b7d21ed3 100644 --- a/src/DownloadContext.cc +++ b/src/DownloadContext.cc @@ -153,24 +153,23 @@ void DownloadContext::setFileFilter(SegList<int> sgl) } void DownloadContext::setAttribute(ContextAttributeType key, - std::unique_ptr<ContextAttribute> value) + std::shared_ptr<ContextAttribute> value) { assert(key < MAX_CTX_ATTR); attrs_[key] = std::move(value); } -const std::unique_ptr<ContextAttribute>& +const std::shared_ptr<ContextAttribute>& DownloadContext::getAttribute(ContextAttributeType key) { assert(key < MAX_CTX_ATTR); - const std::unique_ptr<ContextAttribute>& attr = attrs_[key]; - if (attr) { - return attr; - } - else { + const auto& attr = attrs_[key]; + if (!attr) { throw DL_ABORT_EX( fmt("No attribute named %s", strContextAttributeType(key))); } + + return attr; } bool DownloadContext::hasAttribute(ContextAttributeType key) const @@ -179,6 +178,12 @@ bool DownloadContext::hasAttribute(ContextAttributeType key) const return attrs_[key].get(); } +const std::vector<std::shared_ptr<ContextAttribute>>& +DownloadContext::getAttributes() const +{ + return attrs_; +} + void DownloadContext::releaseRuntimeResource() { for (std::vector<std::shared_ptr<FileEntry>>::const_iterator |
