changeset 69:fe8dab5c051f

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Aug 2015 21:23:42 +0200
parents 45da32410346
children f869ea124433
files Orthanc/Core/Enumerations.cpp Orthanc/Core/Enumerations.h Orthanc/Core/FileStorage/FilesystemStorage.cpp Orthanc/Core/ImageFormats/ImageAccessor.cpp Orthanc/Core/PrecompiledHeaders.h Orthanc/Core/SQLite/Connection.cpp Orthanc/Core/SQLite/Statement.cpp Orthanc/Core/SQLite/StatementReference.cpp Orthanc/Core/Toolbox.cpp Orthanc/Core/Toolbox.h Orthanc/Resources/CMake/JsonCppConfiguration.cmake Orthanc/Resources/CMake/ZlibConfiguration.cmake
diffstat 12 files changed, 89 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/Orthanc/Core/Enumerations.cpp	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/Enumerations.cpp	Fri Aug 07 21:23:42 2015 +0200
@@ -36,6 +36,8 @@
 #include "OrthancException.h"
 #include "Toolbox.h"
 
+#include <string.h>
+
 namespace Orthanc
 {
   const char* EnumerationToString(HttpMethod method)
@@ -368,6 +370,28 @@
   }
 
 
+  const char* EnumerationToString(LogLevel level)
+  {
+    switch (level)
+    {
+      case LogLevel_Error:
+        return "ERROR";
+
+      case LogLevel_Warning:
+        return "WARNING";
+
+      case LogLevel_Info:
+        return "INFO";
+
+      case LogLevel_Trace:
+        return "TRACE";
+
+      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
   Encoding StringToEncoding(const char* encoding)
   {
     std::string s(encoding);
@@ -493,6 +517,31 @@
   }
 
 
+  LogLevel StringToLogLevel(const char *level)
+  {
+    if (strcmp(level, "ERROR") == 0)
+    {
+      return LogLevel_Error;
+    }
+    else if (strcmp(level, "WARNING") == 0)
+    {
+      return LogLevel_Warning;
+    }
+    else if (strcmp(level, "INFO") == 0)
+    {
+      return LogLevel_Info;
+    }
+    else if (strcmp(level, "TRACE") == 0)
+    {
+      return LogLevel_Trace;
+    }
+    else 
+    {
+      throw OrthancException(ErrorCode_InternalError);
+    }
+  }
+
+
   unsigned int GetBytesPerPixel(PixelFormat format)
   {
     switch (format)
--- a/Orthanc/Core/Enumerations.h	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/Enumerations.h	Fri Aug 07 21:23:42 2015 +0200
@@ -76,6 +76,14 @@
     ErrorCode_Plugin
   };
 
+  enum LogLevel
+  {
+    LogLevel_Error,
+    LogLevel_Warning,
+    LogLevel_Info,
+    LogLevel_Trace
+  };
+
 
   /**
    * {summary}{The memory layout of the pixels (resp. voxels) of a 2D (resp. 3D) image.}
@@ -330,12 +338,16 @@
 
   const char* EnumerationToString(PhotometricInterpretation photometric);
 
+  const char* EnumerationToString(LogLevel level);
+
   Encoding StringToEncoding(const char* encoding);
 
   ResourceType StringToResourceType(const char* type);
 
   ImageFormat StringToImageFormat(const char* format);
 
+  LogLevel StringToLogLevel(const char* format);
+
   unsigned int GetBytesPerPixel(PixelFormat format);
 
   bool GetDicomEncoding(Encoding& encoding,
--- a/Orthanc/Core/FileStorage/FilesystemStorage.cpp	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/FileStorage/FilesystemStorage.cpp	Fri Aug 07 21:23:42 2015 +0200
@@ -36,15 +36,13 @@
 // http://stackoverflow.com/questions/1576272/storing-large-number-of-files-in-file-system
 // http://stackoverflow.com/questions/446358/storing-a-large-number-of-images
 
+#include "../Logging.h"
 #include "../OrthancException.h"
 #include "../Toolbox.h"
 #include "../Uuid.h"
 
 #include <boost/filesystem/fstream.hpp>
 
-#if HAVE_GOOGLE_LOG == 1
-#include <glog/logging.h>
-#endif
 
 static std::string ToString(const boost::filesystem::path& p)
 {
@@ -215,7 +213,7 @@
   void FilesystemStorage::Remove(const std::string& uuid,
                                  FileContentType /*type*/)
   {
-#if HAVE_GOOGLE_LOG == 1
+#if ORTHANC_ENABLE_GOOGLE_LOG == 1
     LOG(INFO) << "Deleting file " << uuid;
 #endif
 
--- a/Orthanc/Core/ImageFormats/ImageAccessor.cpp	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/ImageFormats/ImageAccessor.cpp	Fri Aug 07 21:23:42 2015 +0200
@@ -33,6 +33,7 @@
 #include "../PrecompiledHeaders.h"
 #include "ImageAccessor.h"
 
+#include "../Logging.h"
 #include "../OrthancException.h"
 #include "../ChunkedBuffer.h"
 
@@ -40,9 +41,6 @@
 #include <cassert>
 #include <boost/lexical_cast.hpp>
 
-#if HAVE_GOOGLE_LOG == 1
-#include <glog/logging.h>
-#endif
 
 
 namespace Orthanc
@@ -108,7 +106,7 @@
   {
     if (readOnly_)
     {
-#if HAVE_GOOGLE_LOG == 1
+#if ORTHANC_ENABLE_LOGGING == 1
       LOG(ERROR) << "Trying to write on a read-only image";
 #endif
 
@@ -136,7 +134,7 @@
   {
     if (readOnly_)
     {
-#if HAVE_GOOGLE_LOG == 1
+#if ORTHANC_ENABLE_LOGGING == 1
       LOG(ERROR) << "Trying to write on a read-only image";
 #endif
 
--- a/Orthanc/Core/PrecompiledHeaders.h	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/PrecompiledHeaders.h	Fri Aug 07 21:23:42 2015 +0200
@@ -46,7 +46,6 @@
 #include <boost/thread.hpp>
 #include <boost/thread/shared_mutex.hpp>
 
-#include <glog/logging.h>
 #include <json/value.h>
 
 #if ORTHANC_PUGIXML_ENABLED == 1
@@ -54,6 +53,7 @@
 #endif
 
 #include "Enumerations.h"
+#include "Logging.h"
 #include "OrthancException.h"
 #include "Toolbox.h"
 #include "Uuid.h"
--- a/Orthanc/Core/SQLite/Connection.cpp	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/SQLite/Connection.cpp	Fri Aug 07 21:23:42 2015 +0200
@@ -47,7 +47,7 @@
 #include <string.h>
 
 #if ORTHANC_SQLITE_STANDALONE != 1
-#include <glog/logging.h>
+#include "../Logging.h"
 #endif
 
 #include "sqlite3.h"
--- a/Orthanc/Core/SQLite/Statement.cpp	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/SQLite/Statement.cpp	Fri Aug 07 21:23:42 2015 +0200
@@ -47,7 +47,7 @@
 #include <algorithm>
 
 #if ORTHANC_SQLITE_STANDALONE != 1
-#include <glog/logging.h>
+#include "../Logging.h"
 #endif
 
 #include "sqlite3.h"
--- a/Orthanc/Core/SQLite/StatementReference.cpp	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/SQLite/StatementReference.cpp	Fri Aug 07 21:23:42 2015 +0200
@@ -43,7 +43,7 @@
 #include "OrthancSQLiteException.h"
 
 #if ORTHANC_SQLITE_STANDALONE != 1
-#include <glog/logging.h>
+#include "../Logging.h"
 #endif
 
 #include <string>
--- a/Orthanc/Core/Toolbox.cpp	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/Toolbox.cpp	Fri Aug 07 21:23:42 2015 +0200
@@ -34,6 +34,7 @@
 #include "Toolbox.h"
 
 #include "OrthancException.h"
+#include "Logging.h"
 
 #include <string>
 #include <stdint.h>
@@ -53,13 +54,9 @@
 #include <boost/regex.hpp> 
 #endif
 
-#if HAVE_GOOGLE_LOG == 1
-#include <glog/logging.h>
-#endif
-
 #if defined(_WIN32)
 #include <windows.h>
-#include <process.h>   // For "_spawnvp()"
+#include <process.h>   // For "_spawnvp()" and "_getpid()"
 #else
 #include <unistd.h>    // For "execvp()"
 #include <sys/wait.h>  // For "waitpid()"
@@ -440,7 +437,7 @@
     {
       return static_cast<uint64_t>(boost::filesystem::file_size(path));
     }
-    catch (boost::filesystem::filesystem_error)
+    catch (boost::filesystem::filesystem_error&)
     {
       throw OrthancException(ErrorCode_InexistentFile);
     }
@@ -1135,7 +1132,7 @@
     if (pid == -1)
     {
       // Error in fork()
-#if HAVE_GOOGLE_LOG == 1
+#if ORTHANC_ENABLE_LOGGING == 1
       LOG(ERROR) << "Cannot fork a child process";
 #endif
 
@@ -1158,7 +1155,7 @@
 
     if (status != 0)
     {
-#if HAVE_GOOGLE_LOG == 1
+#if ORTHANC_ENABLE_LOGGING == 1
       LOG(ERROR) << "System command failed with status code " << status;
 #endif
 
@@ -1274,5 +1271,14 @@
     }
   }
 
+
+  int Toolbox::GetProcessId()
+  {
+#if defined(_WIN32)
+    return static_cast<int>(_getpid());
+#else
+    return static_cast<int>(getpid());
+#endif
+  }
 }
 
--- a/Orthanc/Core/Toolbox.h	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Core/Toolbox.h	Fri Aug 07 21:23:42 2015 +0200
@@ -170,5 +170,7 @@
 
     bool StartsWith(const std::string& str,
                     const std::string& prefix);
+
+    int GetProcessId();
   }
 }
--- a/Orthanc/Resources/CMake/JsonCppConfiguration.cmake	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Resources/CMake/JsonCppConfiguration.cmake	Fri Aug 07 21:23:42 2015 +0200
@@ -1,8 +1,8 @@
 if (STATIC_BUILD OR NOT USE_SYSTEM_JSONCPP)
-  set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-src-0.6.0-rc2)
+  set(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-0.10.5)
   DownloadPackage(
-    "363e2f4cbd3aeb63bf4e571f377400fb"
-    "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-src-0.6.0-rc2.tar.gz"
+    "db146bac5a126ded9bd728ab7b61ed6b"
+    "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-0.10.5.tar.gz"
     "${JSONCPP_SOURCES_DIR}")
 
   set(JSONCPP_SOURCES
--- a/Orthanc/Resources/CMake/ZlibConfiguration.cmake	Fri Aug 07 21:20:42 2015 +0200
+++ b/Orthanc/Resources/CMake/ZlibConfiguration.cmake	Fri Aug 07 21:23:42 2015 +0200
@@ -1,9 +1,3 @@
-# This is the minizip distribution to create ZIP files
-set(ZLIB_SOURCES
-  ${ORTHANC_ROOT}/Resources/ThirdParty/minizip/ioapi.c
-  ${ORTHANC_ROOT}/Resources/ThirdParty/minizip/zip.c
-  )
-
 if (STATIC_BUILD OR NOT USE_SYSTEM_ZLIB)
   SET(ZLIB_SOURCES_DIR ${CMAKE_BINARY_DIR}/zlib-1.2.7)
   DownloadPackage(