Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h @ 4203:4d42408da117
improving const-correctness in ParsedDicomFile
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Sep 2020 15:01:31 +0200 |
parents | 7112a8af0b63 |
children | 0034f855c023 |
comparison
equal
deleted
inserted
replaced
4202:2007ab69ac16 | 4203:4d42408da117 |
---|---|
93 | 93 |
94 void InvalidateCache(); | 94 void InvalidateCache(); |
95 | 95 |
96 bool EmbedContentInternal(const std::string& dataUriScheme); | 96 bool EmbedContentInternal(const std::string& dataUriScheme); |
97 | 97 |
98 // For internal use only, in order to provide const-correctness on | |
99 // the top of DCMTK API | |
100 DcmFileFormat& GetDcmtkObjectConst() const; | |
101 | |
98 explicit ParsedDicomFile(DcmFileFormat* dicom); // This takes ownership (no clone) | 102 explicit ParsedDicomFile(DcmFileFormat* dicom); // This takes ownership (no clone) |
99 | 103 |
100 public: | 104 public: |
101 explicit ParsedDicomFile(bool createIdentifiers); // Create a minimal DICOM instance | 105 explicit ParsedDicomFile(bool createIdentifiers); // Create a minimal DICOM instance |
102 | 106 |
122 static ParsedDicomFile* AcquireDcmtkObject(DcmFileFormat* dicom) // No clone here | 126 static ParsedDicomFile* AcquireDcmtkObject(DcmFileFormat* dicom) // No clone here |
123 { | 127 { |
124 return new ParsedDicomFile(dicom); | 128 return new ParsedDicomFile(dicom); |
125 } | 129 } |
126 | 130 |
127 DcmFileFormat& GetDcmtkObject() const; | 131 DcmFileFormat& GetDcmtkObject() |
132 { | |
133 return GetDcmtkObjectConst(); | |
134 } | |
128 | 135 |
129 // The "ParsedDicomFile" object cannot be used after calling this method | 136 // The "ParsedDicomFile" object cannot be used after calling this method |
130 DcmFileFormat* ReleaseDcmtkObject(); | 137 DcmFileFormat* ReleaseDcmtkObject(); |
131 | 138 |
132 ParsedDicomFile* Clone(bool keepSopInstanceUid); | 139 ParsedDicomFile* Clone(bool keepSopInstanceUid) const; |
133 | 140 |
134 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 | 141 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 |
135 void SendPathValue(RestApiOutput& output, | 142 void SendPathValue(RestApiOutput& output, |
136 const UriComponents& uri); | 143 const UriComponents& uri) const; |
137 | 144 |
138 void Answer(RestApiOutput& output); | 145 void Answer(RestApiOutput& output) const; |
139 #endif | 146 #endif |
140 | 147 |
141 void Remove(const DicomTag& tag); | 148 void Remove(const DicomTag& tag); |
142 | 149 |
143 // Replace the DICOM tag as a NULL/empty value (e.g. for anonymization) | 150 // Replace the DICOM tag as a NULL/empty value (e.g. for anonymization) |
179 RemovePrivateTagsInternal(&toKeep); | 186 RemovePrivateTagsInternal(&toKeep); |
180 } | 187 } |
181 | 188 |
182 // WARNING: This function handles the decoding of strings to UTF8 | 189 // WARNING: This function handles the decoding of strings to UTF8 |
183 bool GetTagValue(std::string& value, | 190 bool GetTagValue(std::string& value, |
184 const DicomTag& tag); | 191 const DicomTag& tag) const; |
185 | 192 |
186 DicomInstanceHasher GetHasher(); | 193 DicomInstanceHasher GetHasher() const; |
187 | 194 |
195 // The "Save" methods are not tagged as "const", as the internal | |
196 // representation might be changed after serialization | |
188 void SaveToMemoryBuffer(std::string& buffer); | 197 void SaveToMemoryBuffer(std::string& buffer); |
189 | 198 |
190 #if ORTHANC_SANDBOXED == 0 | 199 #if ORTHANC_SANDBOXED == 0 |
191 void SaveToFile(const std::string& path); | 200 void SaveToFile(const std::string& path); |
192 #endif | 201 #endif |
205 void SetEncoding(Encoding encoding); | 214 void SetEncoding(Encoding encoding); |
206 | 215 |
207 void DatasetToJson(Json::Value& target, | 216 void DatasetToJson(Json::Value& target, |
208 DicomToJsonFormat format, | 217 DicomToJsonFormat format, |
209 DicomToJsonFlags flags, | 218 DicomToJsonFlags flags, |
210 unsigned int maxStringLength); | 219 unsigned int maxStringLength) const; |
211 | 220 |
212 void DatasetToJson(Json::Value& target, | 221 void DatasetToJson(Json::Value& target, |
213 DicomToJsonFormat format, | 222 DicomToJsonFormat format, |
214 DicomToJsonFlags flags, | 223 DicomToJsonFlags flags, |
215 unsigned int maxStringLength, | 224 unsigned int maxStringLength, |
216 const std::set<DicomTag>& ignoreTagLength); | 225 const std::set<DicomTag>& ignoreTagLength) const; |
217 | 226 |
218 void HeaderToJson(Json::Value& target, | 227 void HeaderToJson(Json::Value& target, |
219 DicomToJsonFormat format); | 228 DicomToJsonFormat format) const; |
220 | 229 |
221 bool HasTag(const DicomTag& tag) const; | 230 bool HasTag(const DicomTag& tag) const; |
222 | 231 |
223 void EmbedPdf(const std::string& pdf); | 232 void EmbedPdf(const std::string& pdf); |
224 | 233 |
225 bool ExtractPdf(std::string& pdf); | 234 bool ExtractPdf(std::string& pdf) const; |
226 | 235 |
227 void GetRawFrame(std::string& target, // OUT | 236 void GetRawFrame(std::string& target, // OUT |
228 MimeType& mime, // OUT | 237 MimeType& mime, // OUT |
229 unsigned int frameId); // IN | 238 unsigned int frameId) const; // IN |
230 | 239 |
231 unsigned int GetFramesCount() const; | 240 unsigned int GetFramesCount() const; |
232 | 241 |
233 static ParsedDicomFile* CreateFromJson(const Json::Value& value, | 242 static ParsedDicomFile* CreateFromJson(const Json::Value& value, |
234 DicomFromJsonFlags flags, | 243 DicomFromJsonFlags flags, |
251 **/ | 260 **/ |
252 void ExtractDicomSummary(DicomMap& target, | 261 void ExtractDicomSummary(DicomMap& target, |
253 unsigned int maxTagLength, | 262 unsigned int maxTagLength, |
254 const std::set<DicomTag>& ignoreTagLength) const; | 263 const std::set<DicomTag>& ignoreTagLength) const; |
255 | 264 |
256 bool LookupTransferSyntax(std::string& result); | 265 bool LookupTransferSyntax(std::string& result) const; |
257 | 266 |
258 bool LookupPhotometricInterpretation(PhotometricInterpretation& result) const; | 267 bool LookupPhotometricInterpretation(PhotometricInterpretation& result) const; |
259 | 268 |
260 void Apply(ITagVisitor& visitor); | 269 void Apply(ITagVisitor& visitor) const; |
270 | |
271 // Decode the given frame, using the built-in DICOM decoder of Orthanc | |
272 ImageAccessor* DecodeFrame(unsigned int frame) const; | |
261 }; | 273 }; |
262 } | 274 } |