view Plugin/DicomWebFormatter.h @ 250:f2a7dba94df1

new class: DicomWebFormatter
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 Feb 2019 16:05:20 +0100
parents
children 768634772ad7
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-2019 Osimis S.A., Belgium
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Affero 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
 * Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 **/


#pragma once

#include <orthanc/OrthancCPlugin.h>

#include <boost/thread/mutex.hpp>


namespace OrthancPlugins
{
  class DicomWebFormatter : public boost::noncopyable
  {
  private:
    boost::mutex  mutex_;
    std::string   bulkRoot_;

    static DicomWebFormatter& GetSingleton()
    {
      static DicomWebFormatter formatter;
      return formatter;
    }

    static void Callback(OrthancPluginDicomWebNode *node,
                         OrthancPluginDicomWebSetBinaryNode setter,
                         uint32_t levelDepth,
                         const uint16_t *levelTagGroup,
                         const uint16_t *levelTagElement,
                         const uint32_t *levelIndex,
                         uint16_t tagGroup,
                         uint16_t tagElement,
                         OrthancPluginValueRepresentation vr);

  public:
    class Locker : public boost::noncopyable
    {
    private:
      DicomWebFormatter&         that_;
      boost::mutex::scoped_lock  lock_;

    public:
      Locker(const std::string& bulkRoot);

      void Apply(std::string& target,
                 OrthancPluginContext* context,
                 const void* data,
                 size_t size,
                 bool xml);
    };
  };
}