comparison Core/DicomFormat/DicomMap.h @ 0:3959d33612cc

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 19 Jul 2012 14:32:22 +0200
parents
children a15e90e5d6fc
comparison
equal deleted inserted replaced
-1:000000000000 0:3959d33612cc
1 /**
2 * Palantir - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
4 * Belgium
5 *
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20
21 #pragma once
22
23 #include "DicomTag.h"
24 #include "DicomValue.h"
25 #include "DicomString.h"
26
27 #include <map>
28 #include <json/json.h>
29
30 namespace Palantir
31 {
32 class DicomMap : public boost::noncopyable
33 {
34 private:
35 friend class DicomArray;
36 friend class FromDcmtkBridge;
37 friend class ToDcmtkBridge;
38
39 typedef std::map<DicomTag, DicomValue*> Map;
40
41 Map map_;
42
43 // Warning: This takes the ownership of "value"
44 void SetValue(uint16_t group,
45 uint16_t element,
46 DicomValue* value);
47
48 void SetValue(DicomTag tag,
49 DicomValue* value);
50
51 void ExtractTags(DicomMap& source,
52 const DicomTag* tags,
53 size_t count) const;
54
55 public:
56 DicomMap()
57 {
58 }
59
60 ~DicomMap()
61 {
62 Clear();
63 }
64
65 DicomMap* Clone() const;
66
67 void Clear();
68
69 void SetValue(uint16_t group,
70 uint16_t element,
71 const DicomValue& value)
72 {
73 SetValue(group, element, value.Clone());
74 }
75
76 void SetValue(const DicomTag& tag,
77 const DicomValue& value)
78 {
79 SetValue(tag, value.Clone());
80 }
81
82 void SetValue(const DicomTag& tag,
83 const std::string& str)
84 {
85 SetValue(tag, new DicomString(str));
86 }
87
88 void SetValue(uint16_t group,
89 uint16_t element,
90 const std::string& str)
91 {
92 SetValue(group, element, new DicomString(str));
93 }
94
95 bool HasTag(uint16_t group, uint16_t element) const
96 {
97 return HasTag(DicomTag(group, element));
98 }
99
100 bool HasTag(const DicomTag& tag) const
101 {
102 return map_.find(tag) != map_.end();
103 }
104
105 const DicomValue& GetValue(uint16_t group, uint16_t element) const
106 {
107 return GetValue(DicomTag(group, element));
108 }
109
110 const DicomValue& GetValue(const DicomTag& tag) const;
111
112 void Remove(const DicomTag& tag);
113
114 void ExtractPatientInformation(DicomMap& result) const;
115
116 void ExtractStudyInformation(DicomMap& result) const;
117
118 void ExtractSeriesInformation(DicomMap& result) const;
119
120 void ExtractInstanceInformation(DicomMap& result) const;
121
122 static void SetupFindPatientTemplate(DicomMap& result);
123
124 static void SetupFindStudyTemplate(DicomMap& result);
125
126 static void SetupFindSeriesTemplate(DicomMap& result);
127
128 static void SetupFindInstanceTemplate(DicomMap& result);
129
130 void CopyTagIfExists(const DicomMap& source,
131 const DicomTag& tag);
132 };
133 }