Mercurial > hg > orthanc
changeset 5770:e2771185dad6 find-refactoring
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Sep 2024 16:43:47 +0200 |
parents | 0da33161acf7 |
children | 4db9f897df58 |
files | OrthancServer/CMakeLists.txt OrthancServer/Sources/Database/FindRequest.h OrthancServer/Sources/Database/MainDicomTagsRegistry.h OrthancServer/Sources/Search/DatabaseConstraint.cpp OrthancServer/Sources/Search/DatabaseConstraint.h OrthancServer/Sources/Search/DatabaseConstraints.cpp OrthancServer/Sources/Search/DatabaseConstraints.h |
diffstat | 7 files changed, 196 insertions(+), 133 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/CMakeLists.txt Mon Sep 09 16:37:52 2024 +0200 +++ b/OrthancServer/CMakeLists.txt Mon Sep 09 16:43:47 2024 +0200 @@ -126,6 +126,7 @@ ${CMAKE_SOURCE_DIR}/Sources/QueryRetrieveHandler.cpp ${CMAKE_SOURCE_DIR}/Sources/ResourceFinder.cpp ${CMAKE_SOURCE_DIR}/Sources/Search/DatabaseConstraint.cpp + ${CMAKE_SOURCE_DIR}/Sources/Search/DatabaseConstraints.cpp ${CMAKE_SOURCE_DIR}/Sources/Search/DatabaseLookup.cpp ${CMAKE_SOURCE_DIR}/Sources/Search/DicomTagConstraint.cpp ${CMAKE_SOURCE_DIR}/Sources/Search/HierarchicalMatcher.cpp
--- a/OrthancServer/Sources/Database/FindRequest.h Mon Sep 09 16:37:52 2024 +0200 +++ b/OrthancServer/Sources/Database/FindRequest.h Mon Sep 09 16:43:47 2024 +0200 @@ -24,7 +24,7 @@ #pragma once #include "../../../OrthancFramework/Sources/DicomFormat/DicomTag.h" -#include "../Search/DatabaseConstraint.h" +#include "../Search/DatabaseConstraints.h" #include "../Search/DicomTagConstraint.h" #include "../Search/ISqlLookupFormatter.h" #include "../ServerEnumerations.h"
--- a/OrthancServer/Sources/Database/MainDicomTagsRegistry.h Mon Sep 09 16:37:52 2024 +0200 +++ b/OrthancServer/Sources/Database/MainDicomTagsRegistry.h Mon Sep 09 16:43:47 2024 +0200 @@ -24,6 +24,7 @@ #pragma once #include "../Search/DatabaseLookup.h" +#include "../Search/DatabaseConstraints.h" #include <boost/noncopyable.hpp>
--- a/OrthancServer/Sources/Search/DatabaseConstraint.cpp Mon Sep 09 16:37:52 2024 +0200 +++ b/OrthancServer/Sources/Search/DatabaseConstraint.cpp Mon Sep 09 16:43:47 2024 +0200 @@ -109,103 +109,4 @@ constraint.values = (tmpValues.empty() ? NULL : &tmpValues[0]); } #endif - - - void DatabaseConstraints::Clear() - { - for (size_t i = 0; i < constraints_.size(); i++) - { - assert(constraints_[i] != NULL); - delete constraints_[i]; - } - - constraints_.clear(); - } - - - void DatabaseConstraints::AddConstraint(DatabaseConstraint* constraint) - { - if (constraint == NULL) - { - throw OrthancException(ErrorCode_NullPointer); - } - else - { - constraints_.push_back(constraint); - } - } - - - const DatabaseConstraint& DatabaseConstraints::GetConstraint(size_t index) const - { - if (index >= constraints_.size()) - { - throw OrthancException(ErrorCode_ParameterOutOfRange); - } - else - { - assert(constraints_[index] != NULL); - return *constraints_[index]; - } - } - - - std::string DatabaseConstraints::Format() const - { - std::string s; - - for (size_t i = 0; i < constraints_.size(); i++) - { - assert(constraints_[i] != NULL); - const DatabaseConstraint& constraint = *constraints_[i]; - s += "Constraint " + boost::lexical_cast<std::string>(i) + " at " + EnumerationToString(constraint.GetLevel()) + - ": " + constraint.GetTag().Format(); - - switch (constraint.GetConstraintType()) - { - case ConstraintType_Equal: - s += " == " + constraint.GetSingleValue(); - break; - - case ConstraintType_SmallerOrEqual: - s += " <= " + constraint.GetSingleValue(); - break; - - case ConstraintType_GreaterOrEqual: - s += " >= " + constraint.GetSingleValue(); - break; - - case ConstraintType_Wildcard: - s += " ~~ " + constraint.GetSingleValue(); - break; - - case ConstraintType_List: - { - s += " in [ "; - bool first = true; - for (size_t j = 0; j < constraint.GetValuesCount(); j++) - { - if (first) - { - first = false; - } - else - { - s += ", "; - } - s += constraint.GetValue(j); - } - s += "]"; - break; - } - - default: - throw OrthancException(ErrorCode_InternalError); - } - - s += "\n"; - } - - return s; - } }
--- a/OrthancServer/Sources/Search/DatabaseConstraint.h Mon Sep 09 16:37:52 2024 +0200 +++ b/OrthancServer/Sources/Search/DatabaseConstraint.h Mon Sep 09 16:43:47 2024 +0200 @@ -30,8 +30,6 @@ # include "../../Plugins/Include/orthanc/OrthancCDatabasePlugin.h" #endif -#include <deque> - namespace Orthanc { class DatabaseConstraint : public boost::noncopyable @@ -100,35 +98,4 @@ std::vector<const char*>& tmpValues) const; #endif }; - - - class DatabaseConstraints : public boost::noncopyable - { - private: - std::deque<DatabaseConstraint*> constraints_; - - public: - ~DatabaseConstraints() - { - Clear(); - } - - void Clear(); - - void AddConstraint(DatabaseConstraint* constraint); // Takes ownership - - bool IsEmpty() const - { - return constraints_.empty(); - } - - size_t GetSize() const - { - return constraints_.size(); - } - - const DatabaseConstraint& GetConstraint(size_t index) const; - - std::string Format() const; - }; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Sources/Search/DatabaseConstraints.cpp Mon Sep 09 16:43:47 2024 +0200 @@ -0,0 +1,132 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2023 Osimis S.A., Belgium + * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium + * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#include "../PrecompiledHeadersServer.h" +#include "DatabaseConstraints.h" + +#include "../../../OrthancFramework/Sources/OrthancException.h" + +#include <boost/lexical_cast.hpp> +#include <cassert> + + +namespace Orthanc +{ + void DatabaseConstraints::Clear() + { + for (size_t i = 0; i < constraints_.size(); i++) + { + assert(constraints_[i] != NULL); + delete constraints_[i]; + } + + constraints_.clear(); + } + + + void DatabaseConstraints::AddConstraint(DatabaseConstraint* constraint) + { + if (constraint == NULL) + { + throw OrthancException(ErrorCode_NullPointer); + } + else + { + constraints_.push_back(constraint); + } + } + + + const DatabaseConstraint& DatabaseConstraints::GetConstraint(size_t index) const + { + if (index >= constraints_.size()) + { + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + else + { + assert(constraints_[index] != NULL); + return *constraints_[index]; + } + } + + + std::string DatabaseConstraints::Format() const + { + std::string s; + + for (size_t i = 0; i < constraints_.size(); i++) + { + assert(constraints_[i] != NULL); + const DatabaseConstraint& constraint = *constraints_[i]; + s += "Constraint " + boost::lexical_cast<std::string>(i) + " at " + EnumerationToString(constraint.GetLevel()) + + ": " + constraint.GetTag().Format(); + + switch (constraint.GetConstraintType()) + { + case ConstraintType_Equal: + s += " == " + constraint.GetSingleValue(); + break; + + case ConstraintType_SmallerOrEqual: + s += " <= " + constraint.GetSingleValue(); + break; + + case ConstraintType_GreaterOrEqual: + s += " >= " + constraint.GetSingleValue(); + break; + + case ConstraintType_Wildcard: + s += " ~~ " + constraint.GetSingleValue(); + break; + + case ConstraintType_List: + { + s += " in [ "; + bool first = true; + for (size_t j = 0; j < constraint.GetValuesCount(); j++) + { + if (first) + { + first = false; + } + else + { + s += ", "; + } + s += constraint.GetValue(j); + } + s += "]"; + break; + } + + default: + throw OrthancException(ErrorCode_InternalError); + } + + s += "\n"; + } + + return s; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Sources/Search/DatabaseConstraints.h Mon Sep 09 16:43:47 2024 +0200 @@ -0,0 +1,61 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2023 Osimis S.A., Belgium + * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium + * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#pragma once + +#include "DatabaseConstraint.h" + +#include <deque> + +namespace Orthanc +{ + class DatabaseConstraints : public boost::noncopyable + { + private: + std::deque<DatabaseConstraint*> constraints_; + + public: + ~DatabaseConstraints() + { + Clear(); + } + + void Clear(); + + void AddConstraint(DatabaseConstraint* constraint); // Takes ownership + + bool IsEmpty() const + { + return constraints_.empty(); + } + + size_t GetSize() const + { + return constraints_.size(); + } + + const DatabaseConstraint& GetConstraint(size_t index) const; + + std::string Format() const; + }; +}