annotate OrthancServer/DicomModification.h @ 959:bd5659f2a50a

fix possible race condition
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Jun 2014 21:53:50 +0200
parents 331eaf9d9d69
children 2f76b92addd4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #pragma once
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 788
diff changeset
35 #include "ParsedDicomFile.h"
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 namespace Orthanc
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 class DicomModification
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 /**
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 * Process:
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 * (1) Remove private tags
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 * (2) Remove tags specified by the user
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 * (3) Replace tags
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 **/
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 private:
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 typedef std::set<DicomTag> Removals;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 typedef std::map<DicomTag, std::string> Replacements;
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
51 typedef std::map< std::pair<ResourceType, std::string>, std::string> UidMap;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 Removals removals_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 Replacements replacements_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 bool removePrivateTags_;
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
56 ResourceType level_;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 UidMap uidMap_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 void MapDicomIdentifier(ParsedDicomFile& dicom,
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
60 ResourceType level);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 public:
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 DicomModification();
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
65 void Keep(const DicomTag& tag);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 void Remove(const DicomTag& tag);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 bool IsRemoved(const DicomTag& tag) const;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 void Replace(const DicomTag& tag,
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 const std::string& value);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 bool IsReplaced(const DicomTag& tag) const;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 const std::string& GetReplacement(const DicomTag& tag) const;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 void SetRemovePrivateTags(bool removed);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 bool ArePrivateTagsRemoved() const
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 return removePrivateTags_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
85 void SetLevel(ResourceType level);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
87 ResourceType GetLevel() const
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 return level_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 void SetupAnonymization();
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 void Apply(ParsedDicomFile& toModify);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 };
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }