# HG changeset patch # User Sebastien Jodogne # Date 1779452955 -7200 # Node ID 30879dc76b68d8f7687a284bee1f591aaf4aa58d # Parent f1066df740095a1e9678f543d40268d52bb4d7e4 added user data to StorageAreaDataSource diff -r f1066df74009 -r 30879dc76b68 OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp --- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Fri May 22 14:00:29 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp Fri May 22 14:29:15 2026 +0200 @@ -145,16 +145,27 @@ void SetPostProcessing(IPostProcessing* postProcessing) { + std::unique_ptr protection(postProcessing); + if (postProcessing == NULL) { throw OrthancException(ErrorCode_NullPointer); } + else if (postProcessing_.get() != NULL) + { + throw OrthancException(ErrorCode_BadSequenceOfCalls); + } else { - postProcessing_.reset(postProcessing); + postProcessing_.reset(protection.release()); } } + bool HasPostProcessing() const + { + return postProcessing_.get() != NULL; + } + const IPostProcessing& GetPostProcessing() const { if (postProcessing_.get() == NULL) @@ -166,22 +177,6 @@ return *postProcessing_; } } - - boost::shared_ptr ApplyPostProcessing(const boost::shared_ptr& value) const - { - if (value.get() == NULL) - { - throw OrthancException(ErrorCode_NullPointer); - } - else if (postProcessing_.get() == NULL) - { - return value; - } - else - { - return postProcessing_->Apply(value); - } - } }; @@ -316,6 +311,34 @@ } + void StorageAreaDataSource::Range::SetUserData(IDynamicObject* data) + { + std::unique_ptr protection(data); + + if (userData_.get() == NULL) + { + throw OrthancException(ErrorCode_BadSequenceOfCalls); + } + else + { + userData_.reset(data); + } + } + + + const IDynamicObject& StorageAreaDataSource::Range::GetUserData() + { + if (userData_.get() == NULL) + { + throw OrthancException(ErrorCode_BadSequenceOfCalls); + } + else + { + return *userData_; + } + } + + const void* StorageAreaDataSource::Range::GetData() const { return GetValue().GetBuffer().GetData(); @@ -335,12 +358,6 @@ } - StorageAreaDataSource::Range* StorageAreaDataSource::Range::ApplyPostProcessing(const IDataIdentifier& identifier) const - { - return new Range(dynamic_cast(identifier).ApplyPostProcessing(value_)); - } - - StorageAreaDataSource::Range* StorageAreaDataSource::Range::CreateFromSwap(std::string& content) { boost::shared_ptr value(new Value(StringMemoryBuffer::CreateFromSwap(content), false)); @@ -371,11 +388,7 @@ attachment.GetCustomData())); id->SetPostProcessing(new AttachmentPostProcessing(attachment, uncompress)); - std::unique_ptr item(reader.ReadSingleWithIdentifier(id.release())); - - std::unique_ptr range(new Range(item->GetValue())); - - return range->ApplyPostProcessing(item->GetId()); + return Execute(reader, id.release()); } @@ -444,6 +457,42 @@ } + StorageAreaDataSource::Range* StorageAreaDataSource::Execute(DataSourceReader& reader, + IDataIdentifier* request /* takes ownership */) + { + if (request == NULL) + { + throw OrthancException(ErrorCode_NullPointer); + } + else + { + std::unique_ptr item(reader.ReadSingleWithIdentifier(request)); + + const Identifier& id = dynamic_cast(item->GetId()); + + std::unique_ptr range; + + if (id.HasPostProcessing()) + { + range.reset(new Range(id.GetPostProcessing().Apply(item->GetValue()))); + } + else + { + range.reset(new Range(item->GetValue())); + } + + if (item->HasUserData()) + { + range->SetUserData(item->ReleaseUserData()); + } + + return range.release(); + } + } + + + // TODO-Streaming : REMOVE +#if 0 class StorageAreaDataSource::MultipleReader::PImpl : public boost::noncopyable { private: @@ -530,4 +579,5 @@ { return pimpl_->Dequeue(); } +#endif } diff -r f1066df74009 -r 30879dc76b68 OrthancFramework/Sources/DataSource/StorageAreaDataSource.h --- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.h Fri May 22 14:00:29 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.h Fri May 22 14:29:15 2026 +0200 @@ -69,21 +69,28 @@ { private: boost::shared_ptr value_; + std::unique_ptr userData_; const Value& GetValue() const; public: explicit Range(const boost::shared_ptr& value); + void SetUserData(IDynamicObject* data); + + bool HasUserData() const + { + return userData_.get() != NULL; + } + + const IDynamicObject& GetUserData(); + const void* GetData() const; size_t GetSize() const; void Copy(std::string& to) const; - // TODO-Streaming : Post-processing is probably an overkill - Range* ApplyPostProcessing(const IDataIdentifier& identifier) const; - static Range* CreateFromSwap(std::string& content); }; @@ -107,8 +114,12 @@ const StorageRange& range, bool uncompress); + static Range* Execute(DataSourceReader& reader, + IDataIdentifier* request /* takes ownership */); + // TODO-Streaming: Probably to be removed +#if 0 class MultipleReader : public boost::noncopyable { private: @@ -151,5 +162,6 @@ Item* Dequeue(); }; +#endif }; } diff -r f1066df74009 -r 30879dc76b68 OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Fri May 22 14:00:29 2026 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Fri May 22 14:29:15 2026 +0200 @@ -2139,12 +2139,6 @@ } - StorageAreaDataSource::MultipleReader* ServerContext::CreateMultipleStorageAreaReader() const - { - return new StorageAreaDataSource::MultipleReader(storageAreaReader_); - } - - MultipleDicomReader* ServerContext::CreateMultipleDicomReader() const { return new MultipleDicomReader(dicomReader_); diff -r f1066df74009 -r 30879dc76b68 OrthancServer/Sources/ServerContext.h --- a/OrthancServer/Sources/ServerContext.h Fri May 22 14:00:29 2026 +0200 +++ b/OrthancServer/Sources/ServerContext.h Fri May 22 14:29:15 2026 +0200 @@ -591,8 +591,6 @@ Future* SubmitTranscodingRequest(TranscodingCallable* callable); - StorageAreaDataSource::MultipleReader* CreateMultipleStorageAreaReader() const; - MultipleDicomReader* CreateMultipleDicomReader() const; }; }