view Framework/Plugins/GlobalProperties.h @ 221:73cc85f3d9c1

implementation of the "serverIdentifier" information for global properties
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Mar 2021 10:40:34 +0200
parents 3236894320d6
children 35598014f140
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-2021 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 "../Common/DatabaseManager.h"

#define MISSING_SERVER_IDENTIFIER ""


namespace Orthanc
{
  /**
   * The enum "GlobalProperty" below must use same values as in the
   * source code of the Orthanc server:
   * https://hg.orthanc-server.com/orthanc/file/default/OrthancServer/Sources/ServerEnumerations.h
   **/
  
  enum GlobalProperty
  {
    GlobalProperty_DatabaseSchemaVersion = 1,   // Unused in the Orthanc core as of Orthanc 0.9.5
    GlobalProperty_FlushSleep = 2,
    GlobalProperty_AnonymizationSequence = 3,
    GlobalProperty_JobsRegistry = 5,
    GlobalProperty_GetTotalSizeIsFast = 6,      // New in Orthanc 1.5.2
    GlobalProperty_Modalities = 20,             // New in Orthanc 1.5.0
    GlobalProperty_Peers = 21,                  // New in Orthanc 1.5.0

    // Reserved values for internal use by the database plugins
    GlobalProperty_DatabasePatchLevel = 4,
    GlobalProperty_DatabaseInternal0 = 10,
    GlobalProperty_DatabaseInternal1 = 11,
    GlobalProperty_DatabaseInternal2 = 12,
    GlobalProperty_DatabaseInternal3 = 13,
    GlobalProperty_DatabaseInternal4 = 14,
    GlobalProperty_DatabaseInternal5 = 15,
    GlobalProperty_DatabaseInternal6 = 16,
    GlobalProperty_DatabaseInternal7 = 17,
    GlobalProperty_DatabaseInternal8 = 18,
    GlobalProperty_DatabaseInternal9 = 19
  };
}


namespace OrthancDatabases
{
  bool LookupGlobalProperty(std::string& target /* out */,
                            IDatabase& db,
                            ITransaction& transaction,
                            const std::string& serverIdentifier,
                            Orthanc::GlobalProperty property);

  bool LookupGlobalProperty(std::string& target /* out */,
                            DatabaseManager& manager,
                            const std::string& serverIdentifier,
                            Orthanc::GlobalProperty property);

  void SetGlobalProperty(IDatabase& db,
                         ITransaction& transaction,
                         const std::string& serverIdentifier,
                         Orthanc::GlobalProperty property,
                         const std::string& utf8);

  void SetGlobalProperty(DatabaseManager& manager,
                         const std::string& serverIdentifier,
                         Orthanc::GlobalProperty property,
                         const std::string& utf8);

  bool LookupGlobalIntegerProperty(int& target,
                                   IDatabase& db,
                                   ITransaction& transaction,
                                   const std::string& serverIdentifier,
                                   Orthanc::GlobalProperty property);

  void SetGlobalIntegerProperty(IDatabase& db,
                                ITransaction& transaction,
                                const std::string& serverIdentifier,
                                Orthanc::GlobalProperty property,
                                int value);
}