changeset 2394:75c779ca948c

fix compilation without Web server
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Aug 2017 16:23:10 +0200
parents 807ddffc0eeb
children 9496ca5b25ac
files Core/DicomNetworking/IFindRequestHandler.h Core/DicomParsing/ParsedDicomFile.cpp Core/DicomParsing/ParsedDicomFile.h Core/FileStorage/StorageAccessor.cpp Core/FileStorage/StorageAccessor.h
diffstat 5 files changed, 105 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/IFindRequestHandler.h	Wed Aug 30 13:27:05 2017 +0200
+++ b/Core/DicomNetworking/IFindRequestHandler.h	Wed Aug 30 16:23:10 2017 +0200
@@ -35,6 +35,8 @@
 
 #include "DicomFindAnswers.h"
 
+#include <list>
+
 namespace Orthanc
 {
   class IFindRequestHandler : public boost::noncopyable
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Wed Aug 30 13:27:05 2017 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Wed Aug 30 16:23:10 2017 +0200
@@ -146,9 +146,6 @@
 #endif
 
 
-static const char* CONTENT_TYPE_OCTET_STREAM = "application/octet-stream";
-
-
 
 namespace Orthanc
 {
@@ -159,6 +156,33 @@
   };
 
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
+  static const char* CONTENT_TYPE_OCTET_STREAM = "application/octet-stream";
+
+  static void ParseTagAndGroup(DcmTagKey& key,
+                               const std::string& tag)
+  {
+    DicomTag t = FromDcmtkBridge::ParseTag(tag);
+    key = DcmTagKey(t.GetGroup(), t.GetElement());
+  }
+
+  
+  static unsigned int GetPixelDataBlockCount(DcmPixelData& pixelData,
+                                             E_TransferSyntax transferSyntax)
+  {
+    DcmPixelSequence* pixelSequence = NULL;
+    if (pixelData.getEncapsulatedRepresentation
+        (transferSyntax, NULL, pixelSequence).good() && pixelSequence)
+    {
+      return pixelSequence->card();
+    }
+    else
+    {
+      return 1;
+    }
+  }
+
+  
   static void SendPathValueForDictionary(RestApiOutput& output,
                                          DcmItem& dicom)
   {
@@ -178,33 +202,6 @@
     output.AnswerJson(v);
   }
 
-  static inline uint16_t GetCharValue(char c)
-  {
-    if (c >= '0' && c <= '9')
-      return c - '0';
-    else if (c >= 'a' && c <= 'f')
-      return c - 'a' + 10;
-    else if (c >= 'A' && c <= 'F')
-      return c - 'A' + 10;
-    else
-      return 0;
-  }
-
-  static inline uint16_t GetTagValue(const char* c)
-  {
-    return ((GetCharValue(c[0]) << 12) + 
-            (GetCharValue(c[1]) << 8) + 
-            (GetCharValue(c[2]) << 4) + 
-            GetCharValue(c[3]));
-  }
-
-  static void ParseTagAndGroup(DcmTagKey& key,
-                               const std::string& tag)
-  {
-    DicomTag t = FromDcmtkBridge::ParseTag(tag);
-    key = DcmTagKey(t.GetGroup(), t.GetElement());
-  }
-
 
   static void SendSequence(RestApiOutput& output,
                            DcmSequenceOfItems& sequence)
@@ -221,22 +218,6 @@
   }
 
 
-  static unsigned int GetPixelDataBlockCount(DcmPixelData& pixelData,
-                                             E_TransferSyntax transferSyntax)
-  {
-    DcmPixelSequence* pixelSequence = NULL;
-    if (pixelData.getEncapsulatedRepresentation
-        (transferSyntax, NULL, pixelSequence).good() && pixelSequence)
-    {
-      return pixelSequence->card();
-    }
-    else
-    {
-      return 1;
-    }
-  }
-
-
   namespace
   {
     class DicomFieldStream : public IHttpStreamAnswer
@@ -413,7 +394,6 @@
   }
 
 
-
   static void SendPathValueForLeaf(RestApiOutput& output,
                                    const std::string& tag,
                                    DcmItem& dicom,
@@ -441,7 +421,32 @@
       output.AnswerStream(stream);
     }
   }
+#endif
 
+  
+  static inline uint16_t GetCharValue(char c)
+  {
+    if (c >= '0' && c <= '9')
+      return c - '0';
+    else if (c >= 'a' && c <= 'f')
+      return c - 'a' + 10;
+    else if (c >= 'A' && c <= 'F')
+      return c - 'A' + 10;
+    else
+      return 0;
+  }
+
+  
+  static inline uint16_t GetTagValue(const char* c)
+  {
+    return ((GetCharValue(c[0]) << 12) + 
+            (GetCharValue(c[1]) << 8) + 
+            (GetCharValue(c[2]) << 4) + 
+            GetCharValue(c[3]));
+  }
+
+
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
   void ParsedDicomFile::SendPathValue(RestApiOutput& output,
                                       const UriComponents& uri)
   {
@@ -498,7 +503,8 @@
       SendPathValueForLeaf(output, uri.back(), *dicom, transferSyntax);
     }
   }
-
+#endif
+  
 
   void ParsedDicomFile::Remove(const DicomTag& tag)
   {
@@ -782,6 +788,7 @@
   }
 
     
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
   void ParsedDicomFile::Answer(RestApiOutput& output)
   {
     std::string serialized;
@@ -790,7 +797,7 @@
       output.AnswerBuffer(serialized, CONTENT_TYPE_OCTET_STREAM);
     }
   }
-
+#endif
 
 
   bool ParsedDicomFile::GetTagValue(std::string& value,
--- a/Core/DicomParsing/ParsedDicomFile.h	Wed Aug 30 13:27:05 2017 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.h	Wed Aug 30 16:23:10 2017 +0200
@@ -33,12 +33,6 @@
 
 #pragma once
 
-#include "../DicomFormat/DicomInstanceHasher.h"
-#include "../Images/ImageAccessor.h"
-#include "../IDynamicObject.h"
-#include "../RestApi/RestApiOutput.h"
-#include "../Toolbox.h"
-
 #if !defined(ORTHANC_ENABLE_JPEG)
 #  error Macro ORTHANC_ENABLE_JPEG must be defined to use this file
 #endif
@@ -47,6 +41,24 @@
 #  error Macro ORTHANC_ENABLE_PNG must be defined to use this file
 #endif
 
+#if !defined(ORTHANC_ENABLE_CIVETWEB)
+#  error Macro ORTHANC_ENABLE_CIVETWEB must be defined to use this file
+#endif
+
+#if !defined(ORTHANC_ENABLE_MONGOOSE)
+#  error Macro ORTHANC_ENABLE_MONGOOSE must be defined to use this file
+#endif
+
+#include "../DicomFormat/DicomInstanceHasher.h"
+#include "../Images/ImageAccessor.h"
+#include "../IDynamicObject.h"
+#include "../Toolbox.h"
+
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
+#  include "../RestApi/RestApiOutput.h"
+#endif
+
+
 class DcmDataset;
 class DcmFileFormat;
 
@@ -96,10 +108,12 @@
 
     ParsedDicomFile* Clone();
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
     void SendPathValue(RestApiOutput& output,
                        const UriComponents& uri);
 
     void Answer(RestApiOutput& output);
+#endif
 
     void Remove(const DicomTag& tag);
 
--- a/Core/FileStorage/StorageAccessor.cpp	Wed Aug 30 13:27:05 2017 +0200
+++ b/Core/FileStorage/StorageAccessor.cpp	Wed Aug 30 16:23:10 2017 +0200
@@ -36,10 +36,13 @@
 
 #include "../Compression/ZlibCompressor.h"
 #include "../OrthancException.h"
-#include "../HttpServer/HttpStreamTranscoder.h"
 #include "../Toolbox.h"
 #include "../SystemToolbox.h"
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
+#  include "../HttpServer/HttpStreamTranscoder.h"
+#endif
+
 namespace Orthanc
 {
   FileInfo StorageAccessor::Write(const void* data,
@@ -143,6 +146,7 @@
   }
 
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
   void StorageAccessor::SetupSender(BufferHttpSender& sender,
                                     const FileInfo& info,
                                     const std::string& mime)
@@ -168,8 +172,10 @@
 
     sender.SetContentFilename(info.GetUuid() + std::string(extension));
   }
+#endif
 
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
   void StorageAccessor::AnswerFile(HttpOutput& output,
                                    const FileInfo& info,
                                    const std::string& mime)
@@ -180,8 +186,10 @@
     HttpStreamTranscoder transcoder(sender, info.GetCompressionType());
     output.Answer(transcoder);
   }
+#endif
 
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
   void StorageAccessor::AnswerFile(RestApiOutput& output,
                                    const FileInfo& info,
                                    const std::string& mime)
@@ -192,4 +200,5 @@
     HttpStreamTranscoder transcoder(sender, info.GetCompressionType());
     output.AnswerStream(transcoder);
   }
+#endif
 }
--- a/Core/FileStorage/StorageAccessor.h	Wed Aug 30 13:27:05 2017 +0200
+++ b/Core/FileStorage/StorageAccessor.h	Wed Aug 30 16:23:10 2017 +0200
@@ -33,10 +33,21 @@
 
 #pragma once
 
+#if !defined(ORTHANC_ENABLE_CIVETWEB)
+#  error Macro ORTHANC_ENABLE_CIVETWEB must be defined to use this file
+#endif
+
+#if !defined(ORTHANC_ENABLE_MONGOOSE)
+#  error Macro ORTHANC_ENABLE_MONGOOSE must be defined to use this file
+#endif
+
 #include "IStorageArea.h"
 #include "FileInfo.h"
-#include "../HttpServer/BufferHttpSender.h"
-#include "../RestApi/RestApiOutput.h"
+
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
+#  include "../HttpServer/BufferHttpSender.h"
+#  include "../RestApi/RestApiOutput.h"
+#endif
 
 #include <vector>
 #include <string>
@@ -51,9 +62,11 @@
   private:
     IStorageArea&  area_;
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
     void SetupSender(BufferHttpSender& sender,
                      const FileInfo& info,
                      const std::string& mime);
+#endif
 
   public:
     StorageAccessor(IStorageArea& area) : area_(area)
@@ -86,6 +99,7 @@
       area_.Remove(info.GetUuid(), info.GetContentType());
     }
 
+#if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
     void AnswerFile(HttpOutput& output,
                     const FileInfo& info,
                     const std::string& mime);
@@ -93,5 +107,6 @@
     void AnswerFile(RestApiOutput& output,
                     const FileInfo& info,
                     const std::string& mime);
+#endif
   };
 }