view OrthancFramework/Sources/DataSource/StorageAreaDataSource.h @ 6937:093efd260e36 default

fix unit test against old versions DCMTK
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Jun 2026 18:51:51 +0200
parents b60fb4f30c4b
children 6b9b5351d247
line wrap: on
line source

/**
 * Orthanc - A Lightweight, RESTful DICOM Store
 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
 * Department, University Hospital of Liege, Belgium
 * Copyright (C) 2017-2023 Osimis S.A., Belgium
 * Copyright (C) 2024-2026 Orthanc Team SRL, Belgium
 * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 **/


#pragma once

#if !defined(ORTHANC_ENABLE_ZLIB)
#  error The macro ORTHANC_ENABLE_ZLIB must be defined
#endif

#include "../Compatibility.h"
#include "../FileStorage/FileInfo.h"
#include "../FileStorage/IStorageArea.h"
#include "../FileStorage/StorageRange.h"
#include "IDataSource.h"

#include <boost/shared_ptr.hpp>


namespace Orthanc
{
  class DataSourceReader;

  class ORTHANC_PUBLIC StorageAreaDataSource : public IDataSource
  {
  private:
    class Value;
    class Identifier;

  private:
    IPluginStorageArea&  area_;

  public:
    explicit StorageAreaDataSource(IPluginStorageArea& area) :
      area_(area)
    {
    }

    virtual size_t GetValueSize(const IDynamicObject& value) const ORTHANC_OVERRIDE;

    virtual IDynamicObject* Load(const IDataIdentifier& identifier) ORTHANC_OVERRIDE;

    class Range : public boost::noncopyable
    {
    private:
      boost::shared_ptr<IDynamicObject>  value_;

      const Value& GetValue() const;

    public:
      explicit Range(const boost::shared_ptr<IDynamicObject>& value);

      const void* GetData() const;

      size_t GetSize() const;

      void Copy(std::string& to) const;

      static Range* CreateFromSwap(std::string& content);
    };

    static Range* ReadRange(DataSourceReader& reader,
                            const std::string& uuid,
                            FileContentType type,
                            uint64_t start /* inclusive */,
                            uint64_t end /* exclusive */,
                            const std::string& customData);

    static Range* ReadAttachment(DataSourceReader& reader,
                                 const FileInfo& attachment,
                                 bool uncompress,
                                 bool checkMD5);

    static Range* ReadBeginning(DataSourceReader& reader,
                                const FileInfo& attachment,
                                uint64_t untilPosition /* exclusive */);

    static Range* ReadRange(DataSourceReader& reader,
                            const FileInfo& attachment,
                            const StorageRange& range,
                            bool uncompress,
                            bool checkMD5);
  };
}