Mercurial > hg > orthanc
changeset 4304:50b0c69b653a
continued abi
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake Fri Nov 06 16:33:52 2020 +0100 @@ -156,6 +156,7 @@ ${CMAKE_CURRENT_LIST_DIR}/../../Sources/HttpServer/MultipartStreamReader.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/HttpServer/StringMatcher.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Logging.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/OrthancException.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/OrthancFramework.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/SerializationToolbox.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/Toolbox.cpp @@ -198,7 +199,9 @@ ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/JobStepResult.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/Operations/JobOperationValues.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/Operations/LogJobOperation.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/Operations/NullOperationValue.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/Operations/SequenceOfOperationsJob.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/Operations/StringOperationValue.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/SetOfCommandsJob.cpp ${CMAKE_CURRENT_LIST_DIR}/../../Sources/JobsEngine/SetOfInstancesJob.cpp )
--- a/OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py Fri Nov 06 16:33:52 2020 +0100 @@ -145,13 +145,11 @@ ## Ignore pure abstract interfaces, by checking the following ## criteria: ## - It must be a C++ class (not a struct) - ## - The class name must start with "I" ## - All its methods must be pure virtual (abstract) and public ## - Its destructor must be public, virtual, and must do nothing ## - if (child.kind == clang.cindex.CursorKind.CLASS_DECL and - fqn[-1].startswith('I')): + if child.kind == clang.cindex.CursorKind.CLASS_DECL: abstract = True isPublic = False @@ -185,6 +183,9 @@ elif (i.kind == clang.cindex.CursorKind.CLASS_DECL or i.kind == clang.cindex.CursorKind.STRUCT_DECL): ExploreClass(i, fqn + [ i.spelling ]) + elif (i.kind == clang.cindex.CursorKind.TYPEDEF_DECL or # Allow "typedef" + i.kind == clang.cindex.CursorKind.ENUM_DECL): # Allow enums + pass else: abstract = False
--- a/OrthancFramework/Sources/DicomFormat/DicomStreamReader.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/DicomFormat/DicomStreamReader.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -25,6 +25,8 @@ #include "../OrthancException.h" +#include <cassert> + namespace Orthanc { static bool IsNormalizationNeeded(const std::string& source,
--- a/OrthancFramework/Sources/DicomFormat/DicomValue.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/DicomFormat/DicomValue.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -97,6 +97,11 @@ Toolbox::EncodeBase64(target, GetContent()); target.insert(0, "data:" + mime + ";base64,"); } + + void DicomValue::FormatDataUriScheme(std::string& target) const + { + FormatDataUriScheme(target, MIME_BINARY); + } #endif // same as ParseValue but in case the value actually contains a sequence,
--- a/OrthancFramework/Sources/DicomFormat/DicomValue.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/DicomFormat/DicomValue.h Fri Nov 06 16:33:52 2020 +0100 @@ -72,10 +72,7 @@ void FormatDataUriScheme(std::string& target, const std::string& mime) const; - void FormatDataUriScheme(std::string& target) const - { - FormatDataUriScheme(target, MIME_BINARY); - } + void FormatDataUriScheme(std::string& target) const; #endif bool CopyToString(std::string& result,
--- a/OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -34,6 +34,7 @@ #include "FromDcmtkBridge.h" +#include "../Logging.h" #include "../OrthancException.h" #include <dcmtk/dcmdata/dcdeftag.h> @@ -41,6 +42,8 @@ #include <dcmtk/dcmjpeg/djrplol.h> // for DJ_RPLossless #include <dcmtk/dcmjpls/djrparam.h> // for DJLSRepresentationParameter +#include <boost/lexical_cast.hpp> + namespace Orthanc {
--- a/OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -23,6 +23,7 @@ #include "../PrecompiledHeaders.h" #include "DicomWebJsonVisitor.h" +#include "../Logging.h" #include "../OrthancException.h" #include "../Toolbox.h" #include "FromDcmtkBridge.h"
--- a/OrthancFramework/Sources/DicomParsing/MemoryBufferTranscoder.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/DicomParsing/MemoryBufferTranscoder.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -23,6 +23,7 @@ #include "../PrecompiledHeaders.h" #include "MemoryBufferTranscoder.h" +#include "../Logging.h" #include "../OrthancException.h" #include "FromDcmtkBridge.h" @@ -30,6 +31,7 @@ # include "ParsedDicomFile.h" #endif + namespace Orthanc { static void CheckTargetSyntax(const std::string& transcoded,
--- a/OrthancFramework/Sources/HttpServer/MultipartStreamReader.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/HttpServer/MultipartStreamReader.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -27,6 +27,7 @@ #include "../Toolbox.h" #include <boost/algorithm/string/predicate.hpp> +#include <boost/lexical_cast.hpp> #if defined(_MSC_VER) # include <BaseTsd.h> // Definition of ssize_t
--- a/OrthancFramework/Sources/HttpServer/WebDavStorage.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/HttpServer/WebDavStorage.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -23,6 +23,7 @@ #include "../PrecompiledHeaders.h" #include "WebDavStorage.h" +#include "../Logging.h" #include "../OrthancException.h" #include "../SystemToolbox.h" #include "../TemporaryFile.h"
--- a/OrthancFramework/Sources/Images/ImageBuffer.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/Images/ImageBuffer.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -25,6 +25,7 @@ #include "../OrthancException.h" +#include <boost/lexical_cast.hpp> #include <stdio.h> #include <stdlib.h>
--- a/OrthancFramework/Sources/Images/PamReader.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/Images/PamReader.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -24,6 +24,7 @@ #include "PamReader.h" #include "../Endianness.h" +#include "../Logging.h" #include "../OrthancException.h" #include "../Toolbox.h"
--- a/OrthancFramework/Sources/JobsEngine/Operations/JobOperationValue.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/Operations/JobOperationValue.h Fri Nov 06 16:33:52 2020 +0100 @@ -39,24 +39,11 @@ Type_String }; - private: - Type type_; - - protected: - explicit JobOperationValue(Type type) : - type_(type) - { - } - - public: virtual ~JobOperationValue() { } - Type GetType() const - { - return type_; - } + virtual Type GetType() const = 0; virtual JobOperationValue* Clone() const = 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -0,0 +1,44 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/>. + **/ + + +#include "../../PrecompiledHeaders.h" +#include "NullOperationValue.h" + + +namespace Orthanc +{ + JobOperationValue::Type NullOperationValue::GetType() const + { + return Type_Null; + } + + JobOperationValue* NullOperationValue::Clone() const + { + return new NullOperationValue; + } + + void NullOperationValue::Serialize(Json::Value& target) const + { + target = Json::objectValue; + target["Type"] = "Null"; + } +}
--- a/OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.h Fri Nov 06 16:33:52 2020 +0100 @@ -24,25 +24,17 @@ #include "JobOperationValue.h" +#include "../../Compatibility.h" // For ORTHANC_OVERRIDE + namespace Orthanc { class ORTHANC_PUBLIC NullOperationValue : public JobOperationValue { public: - NullOperationValue() : - JobOperationValue(Type_Null) - { - } + virtual Type GetType() const ORTHANC_OVERRIDE; + + virtual JobOperationValue* Clone() const ORTHANC_OVERRIDE; - virtual JobOperationValue* Clone() const ORTHANC_OVERRIDE - { - return new NullOperationValue; - } - - virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE - { - target = Json::objectValue; - target["Type"] = "Null"; - } + virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE; }; }
--- a/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -236,6 +236,17 @@ } + SequenceOfOperationsJob::Lock::Lock(SequenceOfOperationsJob& that) : + that_(that), + lock_(that.mutex_) + { + } + + bool SequenceOfOperationsJob::Lock::IsDone() const + { + return that_.done_; + } + void SequenceOfOperationsJob::Lock::SetTrailingOperationTimeout(unsigned int timeout) { that_.trailingTimeout_ = boost::posix_time::milliseconds(timeout); @@ -257,6 +268,11 @@ return index; } + size_t SequenceOfOperationsJob::Lock::GetOperationsCount() const + { + return that_.operations_.size(); + } + void SequenceOfOperationsJob::Lock::AddInput(size_t index, const JobOperationValue& value) @@ -301,6 +317,11 @@ } + void SequenceOfOperationsJob::Start() + { + } + + JobStepResult SequenceOfOperationsJob::Step(const std::string& jobId) { boost::mutex::scoped_lock lock(mutex_); @@ -361,6 +382,10 @@ } } + void SequenceOfOperationsJob::Stop(JobStopReason reason) + { + } + float SequenceOfOperationsJob::GetProgress() { @@ -370,6 +395,11 @@ static_cast<float>(operations_.size() + 1)); } + void SequenceOfOperationsJob::GetJobType(std::string& target) + { + target = "SequenceOfOperations"; + } + void SequenceOfOperationsJob::GetPublicContent(Json::Value& value) { @@ -407,6 +437,18 @@ return true; } + bool SequenceOfOperationsJob::GetOutput(std::string& output, + MimeType& mime, + const std::string& key) + { + return false; + } + + void SequenceOfOperationsJob::AwakeTrailingSleep() + { + operationAdded_.notify_one(); + } + SequenceOfOperationsJob::SequenceOfOperationsJob(IJobUnserializer& unserializer, const Json::Value& serialized) :
--- a/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h Fri Nov 06 16:33:52 2020 +0100 @@ -85,25 +85,15 @@ boost::mutex::scoped_lock lock_; public: - explicit Lock(SequenceOfOperationsJob& that) : - that_(that), - lock_(that.mutex_) - { - } + explicit Lock(SequenceOfOperationsJob& that); - bool IsDone() const - { - return that_.done_; - } + bool IsDone() const; void SetTrailingOperationTimeout(unsigned int timeout); size_t AddOperation(IJobOperation* operation); - size_t GetOperationsCount() const - { - return that_.operations_.size(); - } + size_t GetOperationsCount() const; void AddInput(size_t index, const JobOperationValue& value); @@ -112,24 +102,17 @@ size_t output); }; - virtual void Start() ORTHANC_OVERRIDE - { - } + virtual void Start() ORTHANC_OVERRIDE; virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE; virtual void Reset() ORTHANC_OVERRIDE; - virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE - { - } + virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE; virtual float GetProgress() ORTHANC_OVERRIDE; - virtual void GetJobType(std::string& target) ORTHANC_OVERRIDE - { - target = "SequenceOfOperations"; - } + virtual void GetJobType(std::string& target) ORTHANC_OVERRIDE; virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE; @@ -137,14 +120,8 @@ virtual bool GetOutput(std::string& output, MimeType& mime, - const std::string& key) ORTHANC_OVERRIDE - { - return false; - } + const std::string& key); - void AwakeTrailingSleep() - { - operationAdded_.notify_one(); - } + void AwakeTrailingSleep(); }; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -0,0 +1,55 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/>. + **/ + + +#include "../../PrecompiledHeaders.h" +#include "StringOperationValue.h" + + +namespace Orthanc +{ + StringOperationValue::StringOperationValue(const std::string& content) : + content_(content) + { + } + + JobOperationValue::Type StringOperationValue::GetType() const + { + return Type_String; + } + + JobOperationValue* StringOperationValue::Clone() const + { + return new StringOperationValue(content_); + } + + const std::string& StringOperationValue::GetContent() const + { + return content_; + } + + void StringOperationValue::Serialize(Json::Value& target) const + { + target = Json::objectValue; + target["Type"] = "String"; + target["Content"] = content_; + } +}
--- a/OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.h Fri Nov 06 16:33:52 2020 +0100 @@ -36,27 +36,14 @@ std::string content_; public: - explicit StringOperationValue(const std::string& content) : - JobOperationValue(JobOperationValue::Type_String), - content_(content) - { - } - - virtual JobOperationValue* Clone() const ORTHANC_OVERRIDE - { - return new StringOperationValue(content_); - } + explicit StringOperationValue(const std::string& content); - const std::string& GetContent() const - { - return content_; - } + virtual Type GetType() const; + + virtual JobOperationValue* Clone() const ORTHANC_OVERRIDE; - virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE - { - target = Json::objectValue; - target["Type"] = "String"; - target["Content"] = content_; - } + const std::string& GetContent() const; + + virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE; }; }
--- a/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -59,6 +59,10 @@ description_ = description; } + const std::string& SetOfCommandsJob::GetDescription() const + { + return description_; + } void SetOfCommandsJob::Reserve(size_t size) {
--- a/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h Fri Nov 06 16:33:52 2020 +0100 @@ -74,10 +74,7 @@ void SetDescription(const std::string& description); - const std::string& GetDescription() const - { - return description_; - } + const std::string& GetDescription() const; void Reserve(size_t size);
--- a/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -127,7 +127,13 @@ { } - + + void SetOfInstancesJob::AddParentResource(const std::string &resource) + { + parentResources_.insert(resource); + } + + void SetOfInstancesJob::AddInstance(const std::string& instance) { AddCommand(new InstanceCommand(*this, instance)); @@ -167,10 +173,25 @@ } } + bool SetOfInstancesJob::HasTrailingStep() const + { + return hasTrailingStep_; + } + + const std::set<std::string> &SetOfInstancesJob::GetFailedInstances() const + { + return failedInstances_; + } + + bool SetOfInstancesJob::IsFailedInstance(const std::string &instance) const + { + return failedInstances_.find(instance) != failedInstances_.end(); + } + void SetOfInstancesJob::Start() { - SetOfCommandsJob::Start(); + SetOfCommandsJob::Start(); } @@ -236,6 +257,4 @@ hasTrailingStep_ = false; } } - - }
--- a/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h Fri Nov 06 16:33:52 2020 +0100 @@ -55,10 +55,7 @@ // Only used for reporting in the public content // https://groups.google.com/d/msg/orthanc-users/9GCV88GLEzw/6wAgP_PRAgAJ - void AddParentResource(const std::string& resource) - { - parentResources_.insert(resource); - } + void AddParentResource(const std::string& resource); void AddInstance(const std::string& instance); @@ -68,20 +65,11 @@ const std::string& GetInstance(size_t index) const; - bool HasTrailingStep() const - { - return hasTrailingStep_; - } + bool HasTrailingStep() const; - const std::set<std::string>& GetFailedInstances() const - { - return failedInstances_; - } + const std::set<std::string>& GetFailedInstances() const; - bool IsFailedInstance(const std::string& instance) const - { - return failedInstances_.find(instance) != failedInstances_.end(); - } + bool IsFailedInstance(const std::string& instance) const; virtual void Start() ORTHANC_OVERRIDE;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancFramework/Sources/OrthancException.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -0,0 +1,116 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/>. + **/ + + +#include "PrecompiledHeaders.h" +#include "OrthancException.h" + +#include "Logging.h" + + +namespace Orthanc +{ + OrthancException::OrthancException(const OrthancException& other) : + errorCode_(other.errorCode_), + httpStatus_(other.httpStatus_) + { + if (other.details_.get() != NULL) + { + details_.reset(new std::string(*other.details_)); + } + } + + OrthancException::OrthancException(ErrorCode errorCode) : + errorCode_(errorCode), + httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)) + { + } + + OrthancException::OrthancException(ErrorCode errorCode, + const std::string& details, + bool log) : + errorCode_(errorCode), + httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)), + details_(new std::string(details)) + { +#if ORTHANC_ENABLE_LOGGING == 1 + if (log) + { + LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; + } +#endif + } + + OrthancException::OrthancException(ErrorCode errorCode, + HttpStatus httpStatus) : + errorCode_(errorCode), + httpStatus_(httpStatus) + { + } + + OrthancException::OrthancException(ErrorCode errorCode, + HttpStatus httpStatus, + const std::string& details, + bool log) : + errorCode_(errorCode), + httpStatus_(httpStatus), + details_(new std::string(details)) + { +#if ORTHANC_ENABLE_LOGGING == 1 + if (log) + { + LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; + } +#endif + } + + ErrorCode OrthancException::GetErrorCode() const + { + return errorCode_; + } + + HttpStatus OrthancException::GetHttpStatus() const + { + return httpStatus_; + } + + const char* OrthancException::What() const + { + return EnumerationToString(errorCode_); + } + + bool OrthancException::HasDetails() const + { + return details_.get() != NULL; + } + + const char* OrthancException::GetDetails() const + { + if (details_.get() == NULL) + { + return ""; + } + else + { + return details_->c_str(); + } + } +}
--- a/OrthancFramework/Sources/OrthancException.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/OrthancException.h Fri Nov 06 16:33:52 2020 +0100 @@ -22,15 +22,10 @@ #pragma once -#include "Compatibility.h" +#include "Compatibility.h" // For std::unique_ptr<> #include "Enumerations.h" -#include "Logging.h" #include "OrthancFramework.h" -#include <stdint.h> -#include <string> -#include <memory> - namespace Orthanc { class ORTHANC_PUBLIC OrthancException @@ -47,90 +42,30 @@ std::unique_ptr<std::string> details_; public: - OrthancException(const OrthancException& other) : - errorCode_(other.errorCode_), - httpStatus_(other.httpStatus_) - { - if (other.details_.get() != NULL) - { - details_.reset(new std::string(*other.details_)); - } - } + OrthancException(const OrthancException& other); - explicit OrthancException(ErrorCode errorCode) : - errorCode_(errorCode), - httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)) - { - } + explicit OrthancException(ErrorCode errorCode); OrthancException(ErrorCode errorCode, const std::string& details, - bool log = true) : - errorCode_(errorCode), - httpStatus_(ConvertErrorCodeToHttpStatus(errorCode)), - details_(new std::string(details)) - { -#if ORTHANC_ENABLE_LOGGING == 1 - if (log) - { - LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; - } -#endif - } + bool log = true); OrthancException(ErrorCode errorCode, - HttpStatus httpStatus) : - errorCode_(errorCode), - httpStatus_(httpStatus) - { - } + HttpStatus httpStatus); OrthancException(ErrorCode errorCode, HttpStatus httpStatus, const std::string& details, - bool log = true) : - errorCode_(errorCode), - httpStatus_(httpStatus), - details_(new std::string(details)) - { -#if ORTHANC_ENABLE_LOGGING == 1 - if (log) - { - LOG(ERROR) << EnumerationToString(errorCode_) << ": " << details; - } -#endif - } + bool log = true); - ErrorCode GetErrorCode() const - { - return errorCode_; - } + ErrorCode GetErrorCode() const; + + HttpStatus GetHttpStatus() const; - HttpStatus GetHttpStatus() const - { - return httpStatus_; - } - - const char* What() const - { - return EnumerationToString(errorCode_); - } + const char* What() const; - bool HasDetails() const - { - return details_.get() != NULL; - } + bool HasDetails() const; - const char* GetDetails() const - { - if (details_.get() == NULL) - { - return ""; - } - else - { - return details_->c_str(); - } - } + const char* GetDetails() const; }; }
--- a/OrthancFramework/Sources/SQLite/Connection.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/Connection.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -175,15 +175,14 @@ } } - int Connection::ExecuteAndReturnErrorCode(const char* sql) + bool Connection::Execute(const std::string &sql) { - CheckIsOpen(); - return sqlite3_exec(db_, sql, NULL, NULL, NULL); + return Execute(sql.c_str()); } // Info querying ------------------------------------------------------------- - bool Connection::IsSQLValid(const char* sql) + bool Connection::IsSQLValid(const char* sql) { sqlite3_stmt* stmt = NULL; if (sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL) != SQLITE_OK) @@ -260,6 +259,22 @@ } + int Connection::ExecuteAndReturnErrorCode(const char* sql) + { + CheckIsOpen(); + return sqlite3_exec(db_, sql, NULL, NULL, NULL); + } + + bool Connection::HasCachedStatement(const StatementId &id) const + { + return cachedStatements_.find(id) != cachedStatements_.end(); + } + + int Connection::GetTransactionNesting() const + { + return transactionNesting_; + } + bool Connection::BeginTransaction() { if (needsRollback_)
--- a/OrthancFramework/Sources/SQLite/Connection.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/Connection.h Fri Nov 06 16:33:52 2020 +0100 @@ -104,10 +104,7 @@ bool Execute(const char* sql); - bool Execute(const std::string& sql) - { - return Execute(sql.c_str()); - } + bool Execute(const std::string& sql); void FlushToDisk(); @@ -155,15 +152,9 @@ int ExecuteAndReturnErrorCode(const char* sql); - bool HasCachedStatement(const StatementId& id) const - { - return cachedStatements_.find(id) != cachedStatements_.end(); - } + bool HasCachedStatement(const StatementId& id) const; - int GetTransactionNesting() const - { - return transactionNesting_; - } + int GetTransactionNesting() const; // Transactions --------------------------------------------------------------
--- a/OrthancFramework/Sources/SQLite/FunctionContext.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/FunctionContext.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -39,6 +39,7 @@ #include "FunctionContext.h" #include "OrthancSQLiteException.h" +#include <cassert> #include <string> #include "sqlite3.h" @@ -74,6 +75,11 @@ return static_cast<SQLite::ColumnType>(sqlite3_value_type(argv_[index])); } + unsigned int FunctionContext::GetParameterCount() const + { + return argc_; + } + int FunctionContext::GetIntValue(unsigned int index) const { CheckIndex(index);
--- a/OrthancFramework/Sources/SQLite/FunctionContext.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/FunctionContext.h Fri Nov 06 16:33:52 2020 +0100 @@ -58,10 +58,7 @@ ColumnType GetColumnType(unsigned int index) const; - unsigned int GetParameterCount() const - { - return argc_; - } + unsigned int GetParameterCount() const; int GetIntValue(unsigned int index) const;
--- a/OrthancFramework/Sources/SQLite/Statement.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/Statement.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -130,6 +130,11 @@ LOG_CREATE(sql); } + Statement::~Statement() + { + Reset(); + } + Statement::Statement(Connection& database, const std::string& sql) :
--- a/OrthancFramework/Sources/SQLite/Statement.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/Statement.h Fri Nov 06 16:33:52 2020 +0100 @@ -105,10 +105,7 @@ const StatementId& id, const char* sql); - ~Statement() - { - Reset(); - } + ~Statement(); bool Run();
--- a/OrthancFramework/Sources/SQLite/StatementId.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/StatementId.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -47,6 +47,13 @@ { namespace SQLite { + Orthanc::SQLite::StatementId::StatementId(const char *file, + int line) : + file_(file), + line_(line) + { + } + bool StatementId::operator< (const StatementId& other) const { if (line_ != other.line_)
--- a/OrthancFramework/Sources/SQLite/StatementId.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/StatementId.h Fri Nov 06 16:33:52 2020 +0100 @@ -56,9 +56,8 @@ StatementId(); // Forbidden public: - StatementId(const char* file, int line) : file_(file), line_(line) - { - } + StatementId(const char* file, + int line); bool operator< (const StatementId& other) const; };
--- a/OrthancFramework/Sources/SQLite/StatementReference.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/StatementReference.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -157,5 +157,11 @@ { return refCount_; } + + sqlite3_stmt *StatementReference::GetWrappedObject() const + { + assert(statement_ != NULL); + return statement_; + } } }
--- a/OrthancFramework/Sources/SQLite/StatementReference.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/StatementReference.h Fri Nov 06 16:33:52 2020 +0100 @@ -47,7 +47,6 @@ #include "SQLiteTypes.h" #include <stdint.h> -#include <cassert> #include <stdlib.h> @@ -76,11 +75,7 @@ uint32_t GetReferenceCount() const; - struct sqlite3_stmt* GetWrappedObject() const - { - assert(statement_ != NULL); - return statement_; - } + struct sqlite3_stmt* GetWrappedObject() const; }; } }
--- a/OrthancFramework/Sources/SQLite/Transaction.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/Transaction.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -60,9 +60,14 @@ } } + bool Transaction::IsOpen() const + { + return isOpen_; + } + void Transaction::Begin() { - if (isOpen_) + if (isOpen_) { throw OrthancSQLiteException(ErrorCode_SQLiteTransactionAlreadyStarted); }
--- a/OrthancFramework/Sources/SQLite/Transaction.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/SQLite/Transaction.h Fri Nov 06 16:33:52 2020 +0100 @@ -59,7 +59,7 @@ virtual ~Transaction(); // Returns true when there is a transaction that has been successfully begun. - bool IsOpen() const { return isOpen_; } + bool IsOpen() const; virtual void Begin();
--- a/OrthancFramework/Sources/TemporaryFile.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/Sources/TemporaryFile.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -28,6 +28,7 @@ #include "Toolbox.h" #include <boost/filesystem.hpp> +#include <boost/lexical_cast.hpp> namespace Orthanc {
--- a/OrthancFramework/UnitTestsSources/DicomMapTests.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/UnitTestsSources/DicomMapTests.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -40,6 +40,7 @@ #include "../Sources/DicomParsing/ParsedDicomFile.h" #include "../Sources/DicomParsing/DicomWebJsonVisitor.h" +#include <boost/lexical_cast.hpp> using namespace Orthanc;
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -47,6 +47,7 @@ #include "../Sources/Images/ImageProcessing.h" #include "../Sources/Images/PngReader.h" #include "../Sources/Images/PngWriter.h" +#include "../Sources/Logging.h" #include "../Sources/OrthancException.h" #include "../Sources/SystemToolbox.h" #include "../Resources/CodeGeneration/EncodingTests.h" @@ -56,6 +57,7 @@ #include <dcmtk/dcmdata/dcvrat.h> #include <boost/algorithm/string/predicate.hpp> +#include <boost/lexical_cast.hpp> #if ORTHANC_ENABLE_PUGIXML == 1 # include <pugixml.hpp>
--- a/OrthancServer/Sources/Database/Compatibility/ICreateInstance.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/Sources/Database/Compatibility/ICreateInstance.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -36,6 +36,9 @@ #include "../../../../OrthancFramework/Sources/OrthancException.h" +#include <cassert> + + namespace Orthanc { namespace Compatibility
--- a/OrthancServer/Sources/OrthancWebDav.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/Sources/OrthancWebDav.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -36,6 +36,7 @@ #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h" #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" #include "../../OrthancFramework/Sources/HttpServer/WebDavStorage.h" +#include "../../OrthancFramework/Sources/Logging.h" #include "Search/DatabaseLookup.h" #include "ServerContext.h"
--- a/OrthancServer/Sources/Search/DatabaseConstraint.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/Sources/Search/DatabaseConstraint.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -47,6 +47,9 @@ # include <OrthancException.h> #endif +#include <cassert> + + namespace Orthanc { namespace Plugins
--- a/OrthancServer/Sources/Search/DatabaseLookup.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/Sources/Search/DatabaseLookup.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -40,6 +40,9 @@ #include "../../../OrthancFramework/Sources/OrthancException.h" #include "../../../OrthancFramework/Sources/Toolbox.h" +#include <boost/lexical_cast.hpp> + + namespace Orthanc { DatabaseLookup::~DatabaseLookup()
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -49,6 +49,9 @@ #include "DatabaseConstraint.h" +#include <boost/lexical_cast.hpp> + + namespace Orthanc { static std::string FormatLevel(ResourceType level)
--- a/OrthancServer/Sources/ServerJobs/Operations/DicomInstanceOperationValue.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/Sources/ServerJobs/Operations/DicomInstanceOperationValue.h Fri Nov 06 16:33:52 2020 +0100 @@ -49,12 +49,16 @@ public: DicomInstanceOperationValue(ServerContext& context, const std::string& id) : - JobOperationValue(Type_DicomInstance), context_(context), id_(id) { } + virtual Type GetType() const + { + return Type_DicomInstance; + } + ServerContext& GetServerContext() const { return context_;
--- a/OrthancServer/Sources/StorageCommitmentReports.h Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/Sources/StorageCommitmentReports.h Fri Nov 06 16:33:52 2020 +0100 @@ -35,6 +35,8 @@ #include "../../OrthancFramework/Sources/Cache/LeastRecentlyUsedIndex.h" +#include <boost/thread/mutex.hpp> + namespace Orthanc { class StorageCommitmentReports : public boost::noncopyable
--- a/OrthancServer/UnitTestsSources/ServerJobsTests.cpp Fri Nov 06 15:37:30 2020 +0100 +++ b/OrthancServer/UnitTestsSources/ServerJobsTests.cpp Fri Nov 06 16:33:52 2020 +0100 @@ -37,6 +37,7 @@ #include "../../OrthancFramework/Sources/Compatibility.h" #include "../../OrthancFramework/Sources/FileStorage/MemoryStorageArea.h" #include "../../OrthancFramework/Sources/JobsEngine/Operations/LogJobOperation.h" +#include "../../OrthancFramework/Sources/Logging.h" #include "../../OrthancFramework/Sources/SerializationToolbox.h" #include "../Sources/Database/SQLiteDatabaseWrapper.h"