Mercurial > hg > orthanc
annotate OrthancFramework/Sources/FileStorage/FilesystemStorage.h @ 4824:6e0305c9ed41 storage-cache
closing branch storage-cache
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 25 Nov 2021 13:26:02 +0100 |
parents | f5cb0c0ffbed |
children | 7053502fbf97 |
rev | line source |
---|---|
0 | 1 /** |
59 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1250
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
136 | 11 * |
0 | 12 * This program is distributed in the hope that it will be useful, but |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
0 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
0 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
4034
78ee0155ec67
trying to use orthanc frameworking with web-viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
25 #include "../OrthancFramework.h" |
78ee0155ec67
trying to use orthanc frameworking with web-viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
26 |
2407
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
27 #if !defined(ORTHANC_SANDBOXED) |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
28 # error The macro ORTHANC_SANDBOXED must be defined |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
29 #endif |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
30 |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
31 #if ORTHANC_SANDBOXED == 1 |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
32 # error The class FilesystemStorage cannot be used in sandboxed environments |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
33 #endif |
5edec967055e
fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
34 |
1124
790ff7a5b3bf
IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1123
diff
changeset
|
35 #include "IStorageArea.h" |
4202
2007ab69ac16
moving ORTHANC_FORCE_INLINE and ORTHANC_OVERRIDE from Enumerations.h to Compatibility.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
36 #include "../Compatibility.h" // For ORTHANC_OVERRIDE |
1124
790ff7a5b3bf
IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1123
diff
changeset
|
37 |
1398 | 38 #include <stdint.h> |
0 | 39 #include <boost/filesystem.hpp> |
40 #include <set> | |
41 | |
59 | 42 namespace Orthanc |
0 | 43 { |
4037
5e26d004838c
adding option "system" to DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4034
diff
changeset
|
44 class ORTHANC_PUBLIC FilesystemStorage : public IStorageArea |
0 | 45 { |
208 | 46 // TODO REMOVE THIS |
47 friend class FilesystemHttpSender; | |
221
e7432706b354
accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
48 friend class FileStorageAccessor; |
0 | 49 |
50 private: | |
51 boost::filesystem::path root_; | |
4185
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
52 bool fsyncOnWrite_; |
0 | 53 |
54 boost::filesystem::path GetPath(const std::string& uuid) const; | |
55 | |
4185
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
56 void Setup(const std::string& root); |
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
57 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
58 #if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
59 // Alias for binary compatibility with Orthanc Framework 1.7.2 => don't use it anymore |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
60 explicit FilesystemStorage(std::string root); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
61 #endif |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
62 |
4484
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
63 #if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1 |
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
64 // Binary compatibility with Orthanc Framework <= 1.8.2 |
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
65 void Read(std::string& content, |
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
66 const std::string& uuid, |
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
67 FileContentType type); |
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
68 #endif |
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
69 |
0 | 70 public: |
4300 | 71 explicit FilesystemStorage(const std::string& root); |
4185
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
72 |
b289a1234822
giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
73 FilesystemStorage(const std::string& root, |
4300 | 74 bool fsyncOnWrite); |
0 | 75 |
1135
67c3c1e4a6e0
index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
76 virtual void Create(const std::string& uuid, |
67c3c1e4a6e0
index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
77 const void* content, |
67c3c1e4a6e0
index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1126
diff
changeset
|
78 size_t size, |
4200 | 79 FileContentType type) ORTHANC_OVERRIDE; |
0 | 80 |
4484
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
81 virtual IMemoryBuffer* Read(const std::string& uuid, |
64f06e7d5fc7
new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
82 FileContentType type) ORTHANC_OVERRIDE; |
0 | 83 |
4495
fa2311f94d9f
IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4484
diff
changeset
|
84 virtual IMemoryBuffer* ReadRange(const std::string& uuid, |
fa2311f94d9f
IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4484
diff
changeset
|
85 FileContentType type, |
fa2311f94d9f
IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4484
diff
changeset
|
86 uint64_t start /* inclusive */, |
fa2311f94d9f
IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4484
diff
changeset
|
87 uint64_t end /* exclusive */) ORTHANC_OVERRIDE; |
fa2311f94d9f
IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4484
diff
changeset
|
88 |
4520
f5cb0c0ffbed
added unit test OrthancFramework.SizeOf to dump sizeof all the public classes in the Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
89 virtual bool HasReadRange() const ORTHANC_OVERRIDE; |
4498
7b99e8bb8246
IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4495
diff
changeset
|
90 |
1126
bf67431a7383
handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
91 virtual void Remove(const std::string& uuid, |
4200 | 92 FileContentType type) ORTHANC_OVERRIDE; |
0 | 93 |
94 void ListAllFiles(std::set<std::string>& result) const; | |
95 | |
1122
1d60316c3618
simplifications in FileStorage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
96 uintmax_t GetSize(const std::string& uuid) const; |
0 | 97 |
98 void Clear(); | |
99 | |
100 uintmax_t GetCapacity() const; | |
101 | |
102 uintmax_t GetAvailableSpace() const; | |
103 }; | |
104 } |