annotate OrthancFramework/Sources/FileStorage/FilesystemStorage.h @ 5640:f7adfb22e20e

updated copyright, as Orthanc Team now replaces Osimis
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 30 May 2024 21:19:57 +0200
parents 48b8dae6dc77
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1398
diff changeset
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * 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
10 * 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
11 * 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
12 * the License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 59
diff changeset
13 *
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * 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
17 * Lesser General Public License for more details.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
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
19 * 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
20 * 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
21 * <http://www.gnu.org/licenses/>.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #pragma once
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
4034
78ee0155ec67 trying to use orthanc frameworking with web-viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
27 #include "../OrthancFramework.h"
78ee0155ec67 trying to use orthanc frameworking with web-viewer plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
28
2407
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
29 #if !defined(ORTHANC_SANDBOXED)
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
30 # error The macro ORTHANC_SANDBOXED must be defined
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
31 #endif
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
32
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
33 #if ORTHANC_SANDBOXED == 1
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
34 # error The class FilesystemStorage cannot be used in sandboxed environments
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
35 #endif
5edec967055e fix sandboxed builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
36
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
37 #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
38 #include "../Compatibility.h" // For ORTHANC_OVERRIDE
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
39
1398
aa9b8fa97576 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
40 #include <stdint.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <boost/filesystem.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <set>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
44 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
4037
5e26d004838c adding option "system" to DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4034
diff changeset
46 class ORTHANC_PUBLIC FilesystemStorage : public IStorageArea
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
208
de640de989b8 HttpFileSender
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 147
diff changeset
48 // TODO REMOVE THIS
de640de989b8 HttpFileSender
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 147
diff changeset
49 friend class FilesystemHttpSender;
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
50 friend class FileStorageAccessor;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 private:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 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
54 bool fsyncOnWrite_;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 boost::filesystem::path GetPath(const std::string& uuid) const;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
4185
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
58 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
59
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
60 #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
61 // 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
62 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
63 #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
64
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
65 #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
66 // 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
67 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
68 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
69 FileContentType type);
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
70 #endif
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
71
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 public:
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
73 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
74
b289a1234822 giving a try to cross-platform compilation of SyncStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
75 FilesystemStorage(const std::string& root,
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
76 bool fsyncOnWrite);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
78 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
79 const void* content,
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
80 size_t size,
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4185
diff changeset
81 FileContentType type) ORTHANC_OVERRIDE;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
4484
64f06e7d5fc7 new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
83 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
84 FileContentType type) ORTHANC_OVERRIDE;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
4495
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
86 virtual IMemoryBuffer* ReadRange(const std::string& uuid,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
87 FileContentType type,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
88 uint64_t start /* inclusive */,
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
89 uint64_t end /* exclusive */) ORTHANC_OVERRIDE;
fa2311f94d9f IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4484
diff changeset
90
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
91 virtual bool HasReadRange() const ORTHANC_OVERRIDE;
4498
7b99e8bb8246 IStorageArea::HasReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4495
diff changeset
92
1126
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
93 virtual void Remove(const std::string& uuid,
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4185
diff changeset
94 FileContentType type) ORTHANC_OVERRIDE;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 void ListAllFiles(std::set<std::string>& result) const;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
1122
1d60316c3618 simplifications in FileStorage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
98 uintmax_t GetSize(const std::string& uuid) const;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 void Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 uintmax_t GetCapacity() const;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 uintmax_t GetAvailableSpace() const;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }