changeset 2924:22524fd06225

macros ORTHANC_OVERRIDE and ORTHANC_FINAL
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Nov 2018 09:06:46 +0100
parents 87366b8aed4f
children a80ba85d89e6
files Core/DicomParsing/ParsedDicomFile.cpp Core/Enumerations.cpp Core/Enumerations.h UnitTestsSources/ImageProcessingTests.cpp UnitTestsSources/MemoryCacheTests.cpp UnitTestsSources/MultiThreadingTests.cpp UnitTestsSources/RestApiTests.cpp UnitTestsSources/SQLiteChromiumTests.cpp UnitTestsSources/SQLiteTests.cpp UnitTestsSources/ServerIndexTests.cpp
diffstat 10 files changed, 71 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -246,27 +246,28 @@
 
       virtual HttpCompression SetupHttpCompression(bool /*gzipAllowed*/,
                                                    bool /*deflateAllowed*/)
+        ORTHANC_OVERRIDE
       {
         // No support for compression
         return HttpCompression_None;
       }
 
-      virtual bool HasContentFilename(std::string& filename)
+      virtual bool HasContentFilename(std::string& filename) ORTHANC_OVERRIDE
       {
         return false;
       }
 
-      virtual std::string GetContentType()
+      virtual std::string GetContentType() ORTHANC_OVERRIDE
       {
         return EnumerationToString(MimeType_Binary);
       }
 
-      virtual uint64_t  GetContentLength()
+      virtual uint64_t  GetContentLength() ORTHANC_OVERRIDE
       {
         return length_;
       }
  
-      virtual bool ReadNextChunk()
+      virtual bool ReadNextChunk() ORTHANC_OVERRIDE
       {
         assert(offset_ <= length_);
 
@@ -299,12 +300,12 @@
         }
       }
  
-      virtual const char *GetChunkContent()
+      virtual const char *GetChunkContent() ORTHANC_OVERRIDE
       {
         return chunk_.c_str();
       }
  
-      virtual size_t GetChunkSize()
+      virtual size_t GetChunkSize() ORTHANC_OVERRIDE
       {
         return chunkSize_;
       }
--- a/Core/Enumerations.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/Core/Enumerations.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -44,6 +44,17 @@
 
 namespace Orthanc
 {
+  static const char* const MIME_CSS = "text/css";
+  static const char* const MIME_DICOM = "application/dicom";
+  static const char* const MIME_GIF = "image/gif";
+  static const char* const MIME_GZIP = "application/gzip";
+  static const char* const MIME_HTML = "text/html";
+  static const char* const MIME_JAVASCRIPT = "application/javascript";
+  static const char* const MIME_JPEG2000 = "image/jp2";
+  static const char* const MIME_PLAIN_TEXT = "text/plain";
+  static const char* const MIME_WEB_ASSEMBLY = "application/wasm";
+  static const char* const MIME_XML_2 = "text/xml";
+
   // This function is autogenerated by the script
   // "Resources/GenerateErrorCodes.py"
   const char* EnumerationToString(ErrorCode error)
--- a/Core/Enumerations.h	Thu Nov 08 17:26:17 2018 +0100
+++ b/Core/Enumerations.h	Fri Nov 09 09:06:46 2018 +0100
@@ -36,6 +36,7 @@
 #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__)
@@ -45,28 +46,32 @@
 #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
+#if __cplusplus >= 201103L
+// C++11 is enabled
+#  define ORTHANC_OVERRIDE  override
+#  define ORTHANC_FINAL     final
+#else
+// C++11 is disabled
+#  define ORTHANC_OVERRIDE
+#  define ORTHANC_FINAL
+#endif
+
+
 namespace Orthanc
 {
   static const char* const URI_SCHEME_PREFIX_BINARY = "data:application/octet-stream;base64,";
 
   static const char* const MIME_BINARY = "application/octet-stream";
-  static const char* const MIME_DICOM = "application/dicom";
   static const char* const MIME_JPEG = "image/jpeg";
-  static const char* const MIME_JPEG2000 = "image/jp2";
   static const char* const MIME_JSON = "application/json";
   static const char* const MIME_JSON_UTF8 = "application/json; charset=utf-8";
-  static const char* const MIME_XML_UTF8 = "application/xml; charset=utf-8";
   static const char* const MIME_PDF = "application/pdf";
   static const char* const MIME_PNG = "image/png";
   static const char* const MIME_XML = "application/xml";
-  static const char* const MIME_XML_2 = "text/xml";
-  static const char* const MIME_HTML = "text/html";
-  static const char* const MIME_PLAIN_TEXT = "text/plain";
-  static const char* const MIME_GZIP = "application/gzip";
-  static const char* const MIME_JAVASCRIPT = "application/javascript";
-  static const char* const MIME_CSS = "text/css";
-  static const char* const MIME_GIF = "image/gif";
-  static const char* const MIME_WEB_ASSEMBLY = "application/wasm";
+  static const char* const MIME_XML_UTF8 = "application/xml; charset=utf-8";
 
   /**
    * "No Internet Media Type (aka MIME type, content type) for PBM has
--- a/UnitTestsSources/ImageProcessingTests.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/UnitTestsSources/ImageProcessingTests.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -94,12 +94,12 @@
     std::auto_ptr<Image>  image_;
 
   protected:
-    virtual void SetUp() 
+    virtual void SetUp() ORTHANC_OVERRIDE
     {
       image_.reset(new Image(ImageTraits::PixelTraits::GetPixelFormat(), 7, 9, false));
     }
 
-    virtual void TearDown()
+    virtual void TearDown() ORTHANC_OVERRIDE
     {
       image_.reset(NULL);
     }
--- a/UnitTestsSources/MemoryCacheTests.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/UnitTestsSources/MemoryCacheTests.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -186,7 +186,7 @@
     {
     }
 
-    virtual ~Integer()
+    virtual ~Integer() ORTHANC_OVERRIDE
     {
       LOG(INFO) << "Removing cache entry for " << value_;
       log_ += boost::lexical_cast<std::string>(value_) + " ";
@@ -198,7 +198,7 @@
   public:
     std::string log_;
 
-    Orthanc::IDynamicObject* Provide(const std::string& s)
+    virtual Orthanc::IDynamicObject* Provide(const std::string& s) ORTHANC_OVERRIDE
     {
       LOG(INFO) << "Providing " << s;
       return new Integer(log_, boost::lexical_cast<int>(s));
--- a/UnitTestsSources/MultiThreadingTests.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/UnitTestsSources/MultiThreadingTests.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -93,15 +93,15 @@
     {
     }
 
-    virtual void Start()
+    virtual void Start() ORTHANC_OVERRIDE
     {
     }
 
-    virtual void Reset()
+    virtual void Reset() ORTHANC_OVERRIDE
     {
     }
     
-    virtual JobStepResult Step()
+    virtual JobStepResult Step() ORTHANC_OVERRIDE
     {
       if (fails_)
       {
@@ -118,28 +118,28 @@
       }
     }
 
-    virtual void Stop(JobStopReason reason)
+    virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE
     {
     }
 
-    virtual float GetProgress()
+    virtual float GetProgress() ORTHANC_OVERRIDE
     {
       return static_cast<float>(count_) / static_cast<float>(steps_ - 1);
     }
 
-    virtual void GetJobType(std::string& type)
+    virtual void GetJobType(std::string& type) ORTHANC_OVERRIDE
     {
       type = "DummyJob";
     }
 
-    virtual bool Serialize(Json::Value& value)
+    virtual bool Serialize(Json::Value& value) ORTHANC_OVERRIDE
     {
       value = Json::objectValue;
       value["Type"] = "DummyJob";
       return true;
     }
 
-    virtual void GetPublicContent(Json::Value& value)
+    virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE
     {
       value["hello"] = "world";
     }
@@ -152,12 +152,12 @@
     bool   trailingStepDone_;
     
   protected:
-    virtual bool HandleInstance(const std::string& instance)
+    virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE
     {
       return (instance != "nope");
     }
 
-    virtual bool HandleTrailingStep()
+    virtual bool HandleTrailingStep() ORTHANC_OVERRIDE
     {
       if (HasTrailingStep())
       {
@@ -201,11 +201,11 @@
       return trailingStepDone_;
     }
     
-    virtual void Stop(JobStopReason reason)
+    virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE
     {
     }
 
-    virtual void GetJobType(std::string& s)
+    virtual void GetJobType(std::string& s) ORTHANC_OVERRIDE
     {
       s = "DummyInstancesJob";
     }
@@ -215,7 +215,7 @@
   class DummyUnserializer : public GenericJobUnserializer
   {
   public:
-    virtual IJob* UnserializeJob(const Json::Value& value)
+    virtual IJob* UnserializeJob(const Json::Value& value) ORTHANC_OVERRIDE
     {
       if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob")
       {
@@ -1286,7 +1286,7 @@
       context_->SetupJobsEngine(true, false);
     }
 
-    virtual ~OrthancJobsSerialization()
+    virtual ~OrthancJobsSerialization() ORTHANC_OVERRIDE
     {
       context_->Stop();
       context_.reset(NULL);
--- a/UnitTestsSources/RestApiTests.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/UnitTestsSources/RestApiTests.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -286,7 +286,7 @@
     virtual bool Visit(const RestApiHierarchy::Resource& resource,
                        const UriComponents& uri,
                        const IHttpHandler::Arguments& components,
-                       const UriComponents& trailing)
+                       const UriComponents& trailing) ORTHANC_OVERRIDE
     {
       return resource.Handle(*(RestApiGetCall*) NULL);
     }
@@ -381,7 +381,7 @@
     }
 
     virtual void Handle(const std::string& type,
-                        const std::string& subtype)
+                        const std::string& subtype) ORTHANC_OVERRIDE
     {
       type_ = type;
       subtype_ = subtype;
--- a/UnitTestsSources/SQLiteChromiumTests.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/UnitTestsSources/SQLiteChromiumTests.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -60,16 +60,16 @@
     {
     }
 
-    virtual ~SQLConnectionTest()
+    virtual ~SQLConnectionTest() ORTHANC_OVERRIDE
     {
     }
 
-    virtual void SetUp() 
+    virtual void SetUp() ORTHANC_OVERRIDE
     {
       db_.OpenInMemory();
     }
 
-    virtual void TearDown() 
+    virtual void TearDown() ORTHANC_OVERRIDE
     {
       db_.Close();
     }
@@ -274,7 +274,7 @@
   class SQLTransactionTest : public SQLConnectionTest
   {
   public:
-    virtual void SetUp()
+    virtual void SetUp() ORTHANC_OVERRIDE
     {
       SQLConnectionTest::SetUp();
       ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)"));
--- a/UnitTestsSources/SQLiteTests.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/UnitTestsSources/SQLiteTests.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -142,22 +142,22 @@
       destroyed = false;
     }
 
-    virtual ~MyFunc()
+    virtual ~MyFunc() ORTHANC_OVERRIDE
     {
       destroyed = true;
     }
 
-    virtual const char* GetName() const
+    virtual const char* GetName() const ORTHANC_OVERRIDE
     {
       return "MYFUNC";
     }
 
-    virtual unsigned int GetCardinality() const
+    virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE
     {
       return 2;
     }
 
-    virtual void Compute(SQLite::FunctionContext& context)
+    virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE
     {
       context.SetIntResult(1000 + context.GetIntValue(0) * context.GetIntValue(1));
     }
@@ -168,17 +168,17 @@
   public:
     std::set<int> deleted_;
 
-    virtual const char* GetName() const
+    virtual const char* GetName() const ORTHANC_OVERRIDE
     {
       return "MYDELETE";
     }
 
-    virtual unsigned int GetCardinality() const
+    virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE
     {
       return 1;
     }
 
-    virtual void Compute(SQLite::FunctionContext& context)
+    virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE
     {
       deleted_.insert(context.GetIntValue(0));
       context.SetNullResult();
--- a/UnitTestsSources/ServerIndexTests.cpp	Thu Nov 08 17:26:17 2018 +0100
+++ b/UnitTestsSources/ServerIndexTests.cpp	Fri Nov 09 09:06:46 2018 +0100
@@ -70,20 +70,21 @@
     }
 
     virtual void SignalRemainingAncestor(ResourceType type,
-                                         const std::string& publicId) 
+                                         const std::string& publicId)
+      ORTHANC_OVERRIDE
     {
       ancestorId_ = publicId;
       ancestorType_ = type;
     }
 
-    virtual void SignalFileDeleted(const FileInfo& info)
+    virtual void SignalFileDeleted(const FileInfo& info) ORTHANC_OVERRIDE
     {
       const std::string fileUuid = info.GetUuid();
       deletedFiles_.push_back(fileUuid);
       LOG(INFO) << "A file must be removed: " << fileUuid;
     }       
 
-    virtual void SignalChange(const ServerIndexChange& change)
+    virtual void SignalChange(const ServerIndexChange& change) ORTHANC_OVERRIDE
     {
       if (change.GetChangeType() == ChangeType_Deleted)
       {
@@ -108,7 +109,7 @@
     {
     }
 
-    virtual void SetUp() 
+    virtual void SetUp()  ORTHANC_OVERRIDE
     {
       listener_.reset(new TestDatabaseListener);
 
@@ -126,7 +127,7 @@
       index_->Open();
     }
 
-    virtual void TearDown()
+    virtual void TearDown() ORTHANC_OVERRIDE
     {
       index_->Close();
       index_.reset(NULL);