Mercurial > hg > orthanc-dicomweb
changeset 64:88e551855cb2
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 13 Aug 2015 12:52:32 +0200 |
parents | dae7a63ff51c |
children | da70170d367e |
files | Orthanc/Core/Enumerations.cpp Orthanc/Core/Enumerations.h Orthanc/Core/Logging.h Orthanc/Core/Toolbox.cpp Orthanc/Resources/CMake/JsonCppConfiguration.cmake |
diffstat | 5 files changed, 106 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Orthanc/Core/Enumerations.cpp Tue Aug 04 15:01:34 2015 +0200 +++ b/Orthanc/Core/Enumerations.cpp Thu Aug 13 12:52:32 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 Tue Aug 04 15:01:34 2015 +0200 +++ b/Orthanc/Core/Enumerations.h Thu Aug 13 12:52:32 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.} @@ -231,6 +239,15 @@ }; + // https://en.wikipedia.org/wiki/HTTP_compression + enum HttpCompression + { + HttpCompression_None, + HttpCompression_Deflate, + HttpCompression_Gzip + }; + + // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ enum Encoding { @@ -292,8 +309,23 @@ enum CompressionType { + /** + * Buffer/file that is stored as-is, in a raw fashion, without + * compression. + **/ CompressionType_None = 1, - CompressionType_Zlib = 2 + + /** + * Buffer that is compressed using the "deflate" algorithm (RFC + * 1951), wrapped inside the zlib data format (RFC 1950), prefixed + * with a "uint64_t" (8 bytes) that encodes the size of the + * uncompressed buffer. If the compressed buffer is empty, its + * represents an empty uncompressed buffer. This format is + * internal to Orthanc. If the 8 first bytes are skipped AND the + * buffer is non-empty, the buffer is compatible with the + * "deflate" HTTP compression. + **/ + CompressionType_ZlibWithSize = 2 }; enum FileContentType @@ -330,12 +362,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/Logging.h Tue Aug 04 15:01:34 2015 +0200 +++ b/Orthanc/Core/Logging.h Thu Aug 13 12:52:32 2015 +0200 @@ -35,12 +35,12 @@ #if ORTHANC_ENABLE_LOGGING == 1 #if ORTHANC_ENABLE_GOOGLE_LOG == 1 -# include <stdlib.h> // This fixes a problem in glog for recent releases of MinGW +# include <stdlib.h> // Including this fixes a problem in glog for recent releases of MinGW # include <glog/logging.h> #else # include <iostream> # include <boost/thread/mutex.hpp> -# define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) +# define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) # define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) #endif @@ -59,28 +59,30 @@ void SetTargetFolder(const std::string& path); +#if ORTHANC_ENABLE_GOOGLE_LOG != 1 + struct NullStream : public std::ostream + { + NullStream() : + std::ios(0), + std::ostream(0) + { + } + }; -#if ORTHANC_ENABLE_GOOGLE_LOG != 1 class InternalLogger { private: - boost::mutex::scoped_lock lock_; - std::ostream* stream_; + boost::mutex::scoped_lock lock_; + NullStream null_; + std::ostream* stream_; public: InternalLogger(const char* level, const char* file, int line); - ~InternalLogger() - { -#if defined(_WIN32) - *stream_ << "\r\n"; -#else - *stream_ << "\n"; -#endif - } - + ~InternalLogger(); + std::ostream& operator<< (const std::string& message) { return (*stream_) << message;
--- a/Orthanc/Core/Toolbox.cpp Tue Aug 04 15:01:34 2015 +0200 +++ b/Orthanc/Core/Toolbox.cpp Thu Aug 13 12:52:32 2015 +0200 @@ -437,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); }
--- a/Orthanc/Resources/CMake/JsonCppConfiguration.cmake Tue Aug 04 15:01:34 2015 +0200 +++ b/Orthanc/Resources/CMake/JsonCppConfiguration.cmake Thu Aug 13 12:52:32 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