changeset 4202:2007ab69ac16

moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Sep 2020 08:35:11 +0200
parents 2d5209153b32
children 4d42408da117
files OrthancFramework/Sources/Compatibility.h OrthancFramework/Sources/Compression/GzipCompressor.h OrthancFramework/Sources/Compression/ZlibCompressor.h OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h OrthancFramework/Sources/Enumerations.h OrthancFramework/Sources/FileStorage/FilesystemStorage.h OrthancFramework/Sources/FileStorage/MemoryStorageArea.h OrthancFramework/Sources/HttpServer/HttpFileSender.h OrthancFramework/Sources/HttpServer/StringHttpOutput.h OrthancFramework/Sources/Images/JpegWriter.h OrthancFramework/Sources/Images/PamWriter.h OrthancFramework/Sources/Images/PixelTraits.h OrthancFramework/Sources/Images/PngWriter.h OrthancFramework/Sources/JobsEngine/GenericJobUnserializer.h OrthancFramework/Sources/JobsEngine/JobsEngine.h OrthancFramework/Sources/JobsEngine/JobsRegistry.h OrthancFramework/Sources/JobsEngine/Operations/LogJobOperation.h OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.h OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.h OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h OrthancFramework/Sources/MetricsRegistry.cpp OrthancServer/Plugins/Engine/PluginsJob.h OrthancServer/Sources/OrthancGetRequestHandler.h
diffstat 26 files changed, 90 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Compatibility.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Compatibility.h	Thu Sep 17 08:35:11 2020 +0200
@@ -22,6 +22,50 @@
 
 #pragma once
 
+
+// Macro "ORTHANC_FORCE_INLINE" forces a function/method to be inlined
+#if defined(_MSC_VER)
+#  define ORTHANC_FORCE_INLINE __forceinline
+#elif defined(__GNUC__) || defined(__clang__) || defined(__EMSCRIPTEN__)
+#  define ORTHANC_FORCE_INLINE inline __attribute((always_inline))
+#else
+#  error Please support your compiler here
+#endif
+
+
+// Macros "ORTHANC_OVERRIDE" and "ORTHANC_FINAL" wrap the "override"
+// and "final" keywords introduced in C++11, to do compile-time
+// checking of virtual methods
+// The __cplusplus macro is broken in Visual Studio up to 15.6 and, in
+// later versions, require the usage of the /Zc:__cplusplus flag
+// We thus use an alternate way of checking for 'override' support
+#ifdef ORTHANC_OVERRIDE_SUPPORTED
+#  error ORTHANC_OVERRIDE_SUPPORTED cannot be defined at this point
+#endif 
+
+#if __cplusplus >= 201103L
+#  define ORTHANC_OVERRIDE_SUPPORTED 1
+#else
+#  ifdef _MSC_VER
+#    if _MSC_VER >= 1600
+#      define ORTHANC_OVERRIDE_SUPPORTED 1
+#    endif
+#  endif
+#endif
+
+
+#if ORTHANC_OVERRIDE_SUPPORTED
+// The override keyword (C++11) is enabled
+#  define ORTHANC_OVERRIDE  override 
+#  define ORTHANC_FINAL     final
+#else
+// The override keyword (C++11) is not available
+#  define ORTHANC_OVERRIDE
+#  define ORTHANC_FINAL
+#endif
+
+
+
 //#define Orthanc_Compatibility_h_STR2(x) #x
 //#define Orthanc_Compatibility_h_STR1(x) Orthanc_Compatibility_h_STR2(x)
 
--- a/OrthancFramework/Sources/Compression/GzipCompressor.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Compression/GzipCompressor.h	Thu Sep 17 08:35:11 2020 +0200
@@ -23,7 +23,7 @@
 #pragma once
 
 #include "DeflateBaseCompressor.h"
-#include "../Enumerations.h"  // For ORTHANC_OVERRIDE
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 namespace Orthanc
 {
--- a/OrthancFramework/Sources/Compression/ZlibCompressor.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Compression/ZlibCompressor.h	Thu Sep 17 08:35:11 2020 +0200
@@ -23,7 +23,7 @@
 #pragma once
 
 #include "DeflateBaseCompressor.h"
-#include "../Enumerations.h"  // For ORTHANC_OVERRIDE
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 namespace Orthanc
 {
--- a/OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.h	Thu Sep 17 08:35:11 2020 +0200
@@ -27,6 +27,7 @@
 #endif
 
 #include "ITagVisitor.h"
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 #include <json/value.h>
 
--- a/OrthancFramework/Sources/Enumerations.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Enumerations.h	Thu Sep 17 08:35:11 2020 +0200
@@ -27,46 +27,6 @@
 #include <string>
 
 
-// Macro "ORTHANC_FORCE_INLINE" forces a function/method to be inlined
-#if defined(_MSC_VER)
-#  define ORTHANC_FORCE_INLINE __forceinline
-#elif defined(__GNUC__) || defined(__clang__) || defined(__EMSCRIPTEN__)
-#  define ORTHANC_FORCE_INLINE inline __attribute((always_inline))
-#else
-#  error Please support your compiler here
-#endif
-
-
-// Macros "ORTHANC_OVERRIDE" and "ORTHANC_FINAL" wrap the "override"
-// and "final" keywords introduced in C++11, to do compile-time
-// checking of virtual methods
-// The __cplusplus macro is broken in Visual Studio up to 15.6 and, in
-// later versions, require the usage of the /Zc:__cplusplus flag
-// We thus use an alternate way of checking for 'override' support
-#ifdef ORTHANC_OVERRIDE_SUPPORTED
-#error ORTHANC_OVERRIDE_SUPPORTED cannot be defined at this point
-#endif 
-
-#if __cplusplus >= 201103L
-#  define ORTHANC_OVERRIDE_SUPPORTED 1
-#else
-#  ifdef _MSC_VER
-#    if _MSC_VER >= 1600
-#      define ORTHANC_OVERRIDE_SUPPORTED 1
-#    endif
-#  endif
-#endif
-
-#if ORTHANC_OVERRIDE_SUPPORTED
-// The override keyword (C++11) is enabled
-#  define ORTHANC_OVERRIDE  override 
-#  define ORTHANC_FINAL     final
-#else
-// The override keyword (C++11) is not available
-#  define ORTHANC_OVERRIDE
-#  define ORTHANC_FINAL
-#endif
-
 namespace Orthanc
 {
   static const char* const URI_SCHEME_PREFIX_BINARY = "data:application/octet-stream;base64,";
--- a/OrthancFramework/Sources/FileStorage/FilesystemStorage.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/FileStorage/FilesystemStorage.h	Thu Sep 17 08:35:11 2020 +0200
@@ -33,6 +33,7 @@
 #endif
 
 #include "IStorageArea.h"
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 #include <stdint.h>
 #include <boost/filesystem.hpp>
--- a/OrthancFramework/Sources/FileStorage/MemoryStorageArea.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/FileStorage/MemoryStorageArea.h	Thu Sep 17 08:35:11 2020 +0200
@@ -24,6 +24,8 @@
 
 #include "IStorageArea.h"
 
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
+
 #include <boost/thread/mutex.hpp>
 #include <map>
 
--- a/OrthancFramework/Sources/HttpServer/HttpFileSender.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/HttpServer/HttpFileSender.h	Thu Sep 17 08:35:11 2020 +0200
@@ -23,6 +23,7 @@
 #pragma once
 
 #include "HttpOutput.h"
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 namespace Orthanc
 {
--- a/OrthancFramework/Sources/HttpServer/StringHttpOutput.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/HttpServer/StringHttpOutput.h	Thu Sep 17 08:35:11 2020 +0200
@@ -25,6 +25,7 @@
 #include "IHttpOutputStream.h"
 
 #include "../ChunkedBuffer.h"
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 namespace Orthanc
 {
--- a/OrthancFramework/Sources/Images/JpegWriter.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Images/JpegWriter.h	Thu Sep 17 08:35:11 2020 +0200
@@ -31,6 +31,7 @@
 #endif
 
 #include "IImageWriter.h"
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 namespace Orthanc
 {
--- a/OrthancFramework/Sources/Images/PamWriter.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Images/PamWriter.h	Thu Sep 17 08:35:11 2020 +0200
@@ -24,6 +24,8 @@
 
 #include "IImageWriter.h"
 
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
+
 namespace Orthanc
 {
   // https://en.wikipedia.org/wiki/Netpbm#PAM_graphics_format
--- a/OrthancFramework/Sources/Images/PixelTraits.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Images/PixelTraits.h	Thu Sep 17 08:35:11 2020 +0200
@@ -22,6 +22,7 @@
 
 #pragma once
 
+#include "../Compatibility.h"  // For ORTHANC_FORCE_INLINE
 #include "../Enumerations.h"
 
 #include <limits>
--- a/OrthancFramework/Sources/Images/PngWriter.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/Images/PngWriter.h	Thu Sep 17 08:35:11 2020 +0200
@@ -31,6 +31,7 @@
 #endif
 
 #include "IImageWriter.h"
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
 
 #include <boost/shared_ptr.hpp>
 
--- a/OrthancFramework/Sources/JobsEngine/GenericJobUnserializer.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/GenericJobUnserializer.h	Thu Sep 17 08:35:11 2020 +0200
@@ -24,15 +24,17 @@
 
 #include "IJobUnserializer.h"
 
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
+
 namespace Orthanc
 {
   class ORTHANC_PUBLIC GenericJobUnserializer : public IJobUnserializer
   {
   public:
-    virtual IJob* UnserializeJob(const Json::Value& value);
+    virtual IJob* UnserializeJob(const Json::Value& value) ORTHANC_OVERRIDE;
 
-    virtual IJobOperation* UnserializeOperation(const Json::Value& value);
+    virtual IJobOperation* UnserializeOperation(const Json::Value& value) ORTHANC_OVERRIDE;
 
-    virtual JobOperationValue* UnserializeValue(const Json::Value& value);
+    virtual JobOperationValue* UnserializeValue(const Json::Value& value) ORTHANC_OVERRIDE;
   };
 }
--- a/OrthancFramework/Sources/JobsEngine/JobsEngine.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/JobsEngine.h	Thu Sep 17 08:35:11 2020 +0200
@@ -59,7 +59,7 @@
                        size_t workerIndex);
 
   public:
-    JobsEngine(size_t maxCompletedJobs);
+    explicit JobsEngine(size_t maxCompletedJobs);
 
     ~JobsEngine();
 
--- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.h	Thu Sep 17 08:35:11 2020 +0200
@@ -129,7 +129,7 @@
                         JobHandler* handler);
 
   public:
-    JobsRegistry(size_t maxCompletedJobs) :
+    explicit JobsRegistry(size_t maxCompletedJobs) :
       maxCompletedJobs_(maxCompletedJobs),
       observer_(NULL)
     {
--- a/OrthancFramework/Sources/JobsEngine/Operations/LogJobOperation.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/Operations/LogJobOperation.h	Thu Sep 17 08:35:11 2020 +0200
@@ -24,15 +24,17 @@
 
 #include "IJobOperation.h"
 
+#include "../../Compatibility.h"  // For ORTHANC_OVERRIDE
+
 namespace Orthanc
 {
   class ORTHANC_PUBLIC LogJobOperation : public IJobOperation
   {
   public:
     virtual void Apply(JobOperationValues& outputs,
-                       const JobOperationValue& input);
+                       const JobOperationValue& input) ORTHANC_OVERRIDE;
 
-    virtual void Serialize(Json::Value& result) const
+    virtual void Serialize(Json::Value& result) const ORTHANC_OVERRIDE
     {
       result = Json::objectValue;
       result["Type"] = "Log";
--- a/OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.h	Thu Sep 17 08:35:11 2020 +0200
@@ -34,12 +34,12 @@
     {
     }
 
-    virtual JobOperationValue* Clone() const
+    virtual JobOperationValue* Clone() const ORTHANC_OVERRIDE
     {
       return new NullOperationValue;
     }
 
-    virtual void Serialize(Json::Value& target) const
+    virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE
     {
       target = Json::objectValue;
       target["Type"] = "Null";
--- a/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h	Thu Sep 17 08:35:11 2020 +0200
@@ -25,6 +25,8 @@
 #include "../IJob.h"
 #include "IJobOperation.h"
 
+#include "../../Compatibility.h"  // For ORTHANC_OVERRIDE
+
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/condition_variable.hpp>
 
--- a/OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.h	Thu Sep 17 08:35:11 2020 +0200
@@ -24,6 +24,8 @@
 
 #include "JobOperationValue.h"
 
+#include "../../Compatibility.h"  // For ORTHANC_OVERRIDE
+
 #include <string>
 
 namespace Orthanc
@@ -40,7 +42,7 @@
     {
     }
 
-    virtual JobOperationValue* Clone() const
+    virtual JobOperationValue* Clone() const ORTHANC_OVERRIDE
     {
       return new StringOperationValue(content_);
     }
@@ -50,7 +52,7 @@
       return content_;
     }
 
-    virtual void Serialize(Json::Value& target) const
+    virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE
     {
       target = Json::objectValue;
       target["Type"] = "String";
--- a/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h	Thu Sep 17 08:35:11 2020 +0200
@@ -24,6 +24,8 @@
 
 #include "IJob.h"
 
+#include "../Compatibility.h"  // For ORTHANC_OVERRIDE
+
 #include <set>
 
 namespace Orthanc
--- a/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp	Thu Sep 17 08:35:11 2020 +0200
@@ -75,7 +75,7 @@
     SetOfInstancesJob& that_;
 
   public:
-    TrailingStepCommand(SetOfInstancesJob& that) :
+    explicit TrailingStepCommand(SetOfInstancesJob& that) :
       that_(that)
     {
     }       
@@ -99,7 +99,7 @@
     SetOfInstancesJob& that_;
 
   public:
-    InstanceUnserializer(SetOfInstancesJob& that) :
+    explicit InstanceUnserializer(SetOfInstancesJob& that) :
       that_(that)
     {
     }
--- a/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h	Thu Sep 17 08:35:11 2020 +0200
@@ -51,7 +51,7 @@
   public:
     SetOfInstancesJob();
 
-    SetOfInstancesJob(const Json::Value& source);  // Unserialization
+    explicit SetOfInstancesJob(const Json::Value& source);  // Unserialization
 
     // Only used for reporting in the public content
     // https://groups.google.com/d/msg/orthanc-users/9GCV88GLEzw/6wAgP_PRAgAJ
@@ -83,12 +83,12 @@
       return failedInstances_.find(instance) != failedInstances_.end();
     }
 
-    virtual void Start();
+    virtual void Start() ORTHANC_OVERRIDE;
 
-    virtual void Reset();
+    virtual void Reset() ORTHANC_OVERRIDE;
 
-    virtual void GetPublicContent(Json::Value& target);
+    virtual void GetPublicContent(Json::Value& target) ORTHANC_OVERRIDE;
 
-    virtual bool Serialize(Json::Value& target);
+    virtual bool Serialize(Json::Value& target) ORTHANC_OVERRIDE;
   };
 }
--- a/OrthancFramework/Sources/MetricsRegistry.cpp	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancFramework/Sources/MetricsRegistry.cpp	Thu Sep 17 08:35:11 2020 +0200
@@ -95,8 +95,9 @@
 
   public:
     Item(MetricsType type) :
-    type_(type),
-    hasValue_(false)
+      type_(type),
+      hasValue_(false),
+      value_(0)
     {
     }
 
--- a/OrthancServer/Plugins/Engine/PluginsJob.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancServer/Plugins/Engine/PluginsJob.h	Thu Sep 17 08:35:11 2020 +0200
@@ -35,6 +35,7 @@
 
 #if ORTHANC_ENABLE_PLUGINS == 1
 
+#include "../../../OrthancFramework/Sources/Compatibility.h"  // For ORTHANC_OVERRIDE
 #include "../../../OrthancFramework/Sources/JobsEngine/IJob.h"
 #include "../Include/orthanc/OrthancCPlugin.h"
 
--- a/OrthancServer/Sources/OrthancGetRequestHandler.h	Thu Sep 17 08:18:28 2020 +0200
+++ b/OrthancServer/Sources/OrthancGetRequestHandler.h	Thu Sep 17 08:35:11 2020 +0200
@@ -32,6 +32,7 @@
 
 #pragma once
 
+#include "../../OrthancFramework/Sources/Compatibility.h"  // For ORTHANC_OVERRIDE
 #include "../../OrthancFramework/Sources/DicomNetworking/IGetRequestHandler.h"
 #include "../../OrthancFramework/Sources/DicomNetworking/RemoteModalityParameters.h"