Mercurial > hg > orthanc
diff OrthancServer/Sources/Database/IDatabaseWrapper.h @ 5807:8279eaab0d1d attach-custom-data
merged default -> attach-custom-data
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 24 Sep 2024 11:39:52 +0200 |
parents | 75e949689c08 68fc5af30c03 |
children | 023a99146dd0 |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/IDatabaseWrapper.h Thu Sep 15 18:13:17 2022 +0200 +++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h Tue Sep 24 11:39:52 2024 +0200 @@ -2,8 +2,9 @@ * Orthanc - A Lightweight, RESTful DICOM Store * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2022 Osimis S.A., Belgium - * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, 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 @@ -26,6 +27,7 @@ #include "../../../OrthancFramework/Sources/FileStorage/FileInfo.h" #include "../../../OrthancFramework/Sources/FileStorage/IStorageArea.h" #include "../ExportedResource.h" +#include "../Search/ISqlLookupFormatter.h" #include "../ServerIndexChange.h" #include "IDatabaseListener.h" @@ -35,14 +37,108 @@ namespace Orthanc { - class DatabaseConstraint; + class DatabaseConstraints; class ResourcesContent; - class IDatabaseWrapper : public boost::noncopyable { public: - struct CreateInstanceResult + class Capabilities + { + private: + bool hasFlushToDisk_; + bool hasRevisionsSupport_; + bool hasLabelsSupport_; + bool hasAtomicIncrementGlobalProperty_; + bool hasUpdateAndGetStatistics_; + bool hasMeasureLatency_; + bool hasAttachmentCustomDataSupport_; + + public: + Capabilities() : + hasFlushToDisk_(false), + hasRevisionsSupport_(false), + hasLabelsSupport_(false), + hasAtomicIncrementGlobalProperty_(false), + hasUpdateAndGetStatistics_(false), + hasMeasureLatency_(false), + hasAttachmentCustomDataSupport_(false) + { + } + + void SetFlushToDisk(bool value) + { + hasFlushToDisk_ = value; + } + + bool HasFlushToDisk() const + { + return hasFlushToDisk_; + } + + void SetRevisionsSupport(bool value) + { + hasRevisionsSupport_ = value; + } + + bool HasRevisionsSupport() const + { + return hasRevisionsSupport_; + } + + void SetLabelsSupport(bool value) + { + hasLabelsSupport_ = value; + } + + bool HasLabelsSupport() const + { + return hasLabelsSupport_; + } + + void SetAttachmentCustomDataSupport(bool value) + { + hasAttachmentCustomDataSupport_ = value; + } + + bool HasAttachmentCustomDataSupport() const + { + return hasAttachmentCustomDataSupport_; + } + + void SetAtomicIncrementGlobalProperty(bool value) + { + hasAtomicIncrementGlobalProperty_ = value; + } + + bool HasAtomicIncrementGlobalProperty() const + { + return hasAtomicIncrementGlobalProperty_; + } + + void SetUpdateAndGetStatistics(bool value) + { + hasUpdateAndGetStatistics_ = value; + } + + bool HasUpdateAndGetStatistics() const + { + return hasUpdateAndGetStatistics_; + } + + void SetMeasureLatency(bool value) + { + hasMeasureLatency_ = value; + } + + bool HasMeasureLatency() const + { + return hasMeasureLatency_; + } + }; + + + struct CreateInstanceResult : public boost::noncopyable { bool isNewPatient_; bool isNewStudy_; @@ -94,13 +190,13 @@ virtual void GetAllPublicIds(std::list<std::string>& target, ResourceType resourceType, - size_t since, - size_t limit) = 0; + int64_t since, + uint32_t limit) = 0; virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) = 0; + uint32_t limit) = 0; virtual void GetChildrenInternalId(std::list<int64_t>& target, int64_t id) = 0; @@ -111,7 +207,7 @@ virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/, bool& done /*out*/, int64_t since, - uint32_t maxResults) = 0; + uint32_t limit) = 0; virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) = 0; @@ -130,15 +226,16 @@ virtual uint64_t GetTotalUncompressedSize() = 0; - virtual bool IsExistingResource(int64_t internalId) = 0; - virtual bool IsProtectedPatient(int64_t internalId) = 0; virtual void ListAvailableAttachments(std::set<FileContentType>& target, int64_t id) = 0; - virtual void LogChange(int64_t internalId, - const ServerIndexChange& change) = 0; + virtual void LogChange(ChangeType changeType, + ResourceType resourceType, + int64_t internalId, + const std::string& publicId, /* only for compatibility with V1 and V2 plugins */ + const std::string& date) = 0; virtual void LogExportedResource(const ExportedResource& resource) = 0; @@ -197,9 +294,11 @@ virtual void ApplyLookupResources(std::list<std::string>& resourcesId, std::list<std::string>* instancesId, // Can be NULL if not needed - const std::vector<DatabaseConstraint>& lookup, + const DatabaseConstraints& lookup, ResourceType queryLevel, - size_t limit) = 0; + const std::set<std::string>& labels, + LabelsConstraint labelsConstraint, + uint32_t limit) = 0; // Returns "true" iff. the instance is new and has been inserted // into the database. If "false" is returned, the content of @@ -235,6 +334,35 @@ ResourceType& type, std::string& parentPublicId, const std::string& publicId) = 0; + + + /** + * Primitives introduced in Orthanc 1.12.0 + **/ + + virtual void AddLabel(int64_t resource, + const std::string& label) = 0; + + virtual void RemoveLabel(int64_t resource, + const std::string& label) = 0; + + // List the labels of one single resource + virtual void ListLabels(std::set<std::string>& target, + int64_t resource) = 0; + + // List all the labels that are present in any resource + virtual void ListAllLabels(std::set<std::string>& target) = 0; + + virtual int64_t IncrementGlobalProperty(GlobalProperty property, + int64_t increment, + bool shared) = 0; + + virtual void UpdateAndGetStatistics(int64_t& patientsCount, + int64_t& studiesCount, + int64_t& seriesCount, + int64_t& instancesCount, + int64_t& compressedSize, + int64_t& uncompressedSize) = 0; }; @@ -248,8 +376,6 @@ virtual void FlushToDisk() = 0; - virtual bool HasFlushToDisk() const = 0; - virtual ITransaction* StartTransaction(TransactionType type, IDatabaseListener& listener) = 0; @@ -258,8 +384,8 @@ virtual void Upgrade(unsigned int targetVersion, IStorageArea& storageArea) = 0; - virtual bool HasRevisionsSupport() const = 0; + virtual const Capabilities GetDatabaseCapabilities() const = 0; - virtual bool HasAttachmentCustomDataSupport() const = 0; + virtual uint64_t MeasureLatency() = 0; }; }