Mercurial > hg > orthanc
changeset 6867:ff73909042f2 streaming
refactoring constructor of StorageAreaDataSource::Range
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 26 May 2026 17:54:14 +0200 |
| parents | 4bd9dd9e3b9c |
| children | 276cc0b60611 |
| files | OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp |
| diffstat | 1 files changed, 21 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Tue May 26 16:22:09 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Tue May 26 17:54:14 2026 +0200 @@ -301,7 +301,7 @@ } - StorageAreaDataSource::Range::Range(IMemoryBuffer* buffer /* takes ownership */) : + StorageAreaDataSource::Range::Range(IMemoryBuffer* buffer) : buffer_(buffer) { if (buffer == NULL) @@ -318,6 +318,25 @@ { throw OrthancException(ErrorCode_NullPointer); } + + const Identifier& id = dynamic_cast<const Identifier&>(item->GetId()); + + if (id.HasPostProcessing()) + { + const Value& value = dynamic_cast<const Value&>(*item->GetValue()); + std::unique_ptr<IMemoryBuffer> postProcessed(id.GetPostProcessing().Apply(value)); + + if (postProcessed.get() != NULL) + { + // In this case, the backpressure on the source "item" is released + item_.reset(NULL); + buffer_.reset(postProcessed.release()); + } + else + { + // No postprocessing was applied, keep backpressure on "item" + } + } } @@ -417,32 +436,7 @@ } else { - std::unique_ptr<DataSourceAnswer::Item> item(reader.ReadSingle(request)); - - const Identifier& id = dynamic_cast<const Identifier&>(item->GetId()); - - std::unique_ptr<Range> range; - - if (id.HasPostProcessing()) - { - const Value& value = dynamic_cast<const Value&>(*item->GetValue()); - std::unique_ptr<IMemoryBuffer> postProcessed(id.GetPostProcessing().Apply(value)); - - if (postProcessed.get() != NULL) - { - range.reset(new Range(postProcessed.release())); - } - } - - if (range.get() == NULL) // No postprocessing was applied - { - return new Range(item.release()); // Keep backpressure on "item" - } - else - { - // In this case, the backporessure on the source "item" is released - return range.release(); - } + return new Range(reader.ReadSingle(request)); } } }
