annotate OrthancFramework/Sources/Images/PamReader.h @ 5858:66fd63b8601e find-refactoring tip

StorageAccessOnFind: cont
author Alain Mazy <am@orthanc.team>
date Mon, 04 Nov 2024 22:34:14 +0100
parents f7adfb22e20e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
1 /**
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
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
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
8 *
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
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: 4063
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: 4063
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: 4063
diff changeset
12 * the License, or (at your option) any later version.
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
13 *
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
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: 4063
diff changeset
17 * Lesser General Public License for more details.
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
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: 4063
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: 4063
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: 4063
diff changeset
21 * <http://www.gnu.org/licenses/>.
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
22 **/
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
23
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
24
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
25 #pragma once
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
26
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
27 #include "ImageAccessor.h"
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
28
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
29 #if !defined(ORTHANC_SANDBOXED)
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
30 # error The macro ORTHANC_SANDBOXED must be defined
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
31 #endif
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
32
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
33 namespace Orthanc
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
34 {
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
35 class ORTHANC_PUBLIC PamReader : public ImageAccessor
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
36 {
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
37 private:
2705
5c18a22cb981 fix portability of PAM reader/writer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2702
diff changeset
38 void ParseContent();
5c18a22cb981 fix portability of PAM reader/writer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2702
diff changeset
39
3834
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
40 /**
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
41 Whether we want to use the default malloc alignment in the image buffer,
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
42 at the expense of an extra copy
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
43 */
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
44 bool enforceAligned_;
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
45
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
46 /**
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
47 This is actually a copy of wrappedContent_, but properly aligned.
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
48
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
49 It is only used if the enforceAligned parameter is set to true in the
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
50 constructor.
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
51 */
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
52 void* alignedImageBuffer_;
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
53
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
54 /**
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
55 Points somewhere in the content_ buffer.
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
56 */
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
57 ImageAccessor wrappedContent_;
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
58
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
59 /**
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
60 Raw content (file bytes or answer from the server, for instance).
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
61 */
2705
5c18a22cb981 fix portability of PAM reader/writer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2702
diff changeset
62 std::string content_;
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
63
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
64 public:
3834
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
65 /**
4211
afad57ac30ef enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
66 See doc for field enforceAligned_. Setting "enforceAligned" is slower,
afad57ac30ef enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
67 but avoids possible crashes due to non-aligned memory access. It is
afad57ac30ef enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
68 recommended to set this parameter to "true".
3834
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
69 */
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4211
diff changeset
70 explicit PamReader(bool enforceAligned);
3834
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
71
3838
95083d2f6819 fix build on os x
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3834
diff changeset
72 virtual ~PamReader();
3455
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
73
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
74 #if ORTHANC_SANDBOXED == 0
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
75 void ReadFromFile(const std::string& filename);
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
76 #endif
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
77
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
78 void ReadFromMemory(const std::string& buffer);
2919
2ca9cd064b15 PamReader::ReadFromMemory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
79
2ca9cd064b15 PamReader::ReadFromMemory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
80 void ReadFromMemory(const void* buffer,
2ca9cd064b15 PamReader::ReadFromMemory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
81 size_t size);
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
82 };
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
83 }