annotate OrthancFramework/Sources/Images/PamReader.h @ 5044:6fed78e13233

Refactored DicomMap to handle sequences when needed
author Alain Mazy <am@osimis.io>
date Tue, 28 Jun 2022 17:45:09 +0200
parents 43e613a7756b
children 0ea402b4d901
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
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 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
7 *
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * 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
12 *
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * 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
17 *
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
18 * 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
19 * 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
20 * <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
21 **/
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 #pragma once
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
25
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
26 #include "ImageAccessor.h"
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
27
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
28 #if !defined(ORTHANC_SANDBOXED)
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
29 # 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
30 #endif
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
31
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
32 namespace Orthanc
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
33 {
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
34 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
35 {
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
36 private:
2705
5c18a22cb981 fix portability of PAM reader/writer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2702
diff changeset
37 void ParseContent();
5c18a22cb981 fix portability of PAM reader/writer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2702
diff changeset
38
3834
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
39 /**
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
40 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
41 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
42 */
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
43 bool enforceAligned_;
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
44
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 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
47
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
48 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
49 constructor.
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
50 */
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
51 void* alignedImageBuffer_;
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
52
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 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
55 */
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
56 ImageAccessor wrappedContent_;
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
57
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 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
60 */
2705
5c18a22cb981 fix portability of PAM reader/writer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2702
diff changeset
61 std::string content_;
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
62
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
63 public:
3834
219de90c1f43 Added a flag to use an extra buffer in PamReader
Benjamin Golinvaux <bgo@osimis.io>
parents: 3640
diff changeset
64 /**
4211
afad57ac30ef enforcing parameter "enforceAligned" in PamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
65 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
66 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
67 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
68 */
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4211
diff changeset
69 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
70
3838
95083d2f6819 fix build on os x
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3834
diff changeset
71 virtual ~PamReader();
3455
Alain Mazy <alain@mazy.be>
parents: 3060
diff changeset
72
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
73 #if ORTHANC_SANDBOXED == 0
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
74 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
75 #endif
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
76
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
77 void ReadFromMemory(const std::string& buffer);
2919
2ca9cd064b15 PamReader::ReadFromMemory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
78
2ca9cd064b15 PamReader::ReadFromMemory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
79 void ReadFromMemory(const void* buffer,
2ca9cd064b15 PamReader::ReadFromMemory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2861
diff changeset
80 size_t size);
2699
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
81 };
52217dc47a4e new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
diff changeset
82 }