Mercurial > hg > orthanc
comparison OrthancFramework/Sources/FileStorage/FileInfo.cpp @ 5080:d7274e43ea7c attach-custom-data
allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 08 Sep 2022 17:42:08 +0200 |
parents | 43e613a7756b |
children | 8279eaab0d1d |
comparison
equal
deleted
inserted
replaced
5079:4366b4c41441 | 5080:d7274e43ea7c |
---|---|
39 | 39 |
40 | 40 |
41 FileInfo::FileInfo(const std::string& uuid, | 41 FileInfo::FileInfo(const std::string& uuid, |
42 FileContentType contentType, | 42 FileContentType contentType, |
43 uint64_t size, | 43 uint64_t size, |
44 const std::string& md5) : | 44 const std::string& md5, |
45 const std::string& customData) : | |
45 valid_(true), | 46 valid_(true), |
46 uuid_(uuid), | 47 uuid_(uuid), |
47 contentType_(contentType), | 48 contentType_(contentType), |
48 uncompressedSize_(size), | 49 uncompressedSize_(size), |
49 uncompressedMD5_(md5), | 50 uncompressedMD5_(md5), |
50 compressionType_(CompressionType_None), | 51 compressionType_(CompressionType_None), |
51 compressedSize_(size), | 52 compressedSize_(size), |
52 compressedMD5_(md5) | 53 compressedMD5_(md5), |
54 customData_(customData) | |
53 { | 55 { |
54 } | 56 } |
55 | 57 |
56 | 58 |
57 FileInfo::FileInfo(const std::string& uuid, | 59 FileInfo::FileInfo(const std::string& uuid, |
58 FileContentType contentType, | 60 FileContentType contentType, |
59 uint64_t uncompressedSize, | 61 uint64_t uncompressedSize, |
60 const std::string& uncompressedMD5, | 62 const std::string& uncompressedMD5, |
61 CompressionType compressionType, | 63 CompressionType compressionType, |
62 uint64_t compressedSize, | 64 uint64_t compressedSize, |
63 const std::string& compressedMD5) : | 65 const std::string& compressedMD5, |
66 const std::string& customData) : | |
64 valid_(true), | 67 valid_(true), |
65 uuid_(uuid), | 68 uuid_(uuid), |
66 contentType_(contentType), | 69 contentType_(contentType), |
67 uncompressedSize_(uncompressedSize), | 70 uncompressedSize_(uncompressedSize), |
68 uncompressedMD5_(uncompressedMD5), | 71 uncompressedMD5_(uncompressedMD5), |
69 compressionType_(compressionType), | 72 compressionType_(compressionType), |
70 compressedSize_(compressedSize), | 73 compressedSize_(compressedSize), |
71 compressedMD5_(compressedMD5) | 74 compressedMD5_(compressedMD5), |
75 customData_(customData) | |
72 { | 76 { |
73 } | 77 } |
74 | 78 |
75 | 79 |
76 bool FileInfo::IsValid() const | 80 bool FileInfo::IsValid() const |
166 else | 170 else |
167 { | 171 { |
168 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 172 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
169 } | 173 } |
170 } | 174 } |
175 | |
176 const std::string& FileInfo::GetCustomData() const | |
177 { | |
178 if (valid_) | |
179 { | |
180 return customData_; | |
181 } | |
182 else | |
183 { | |
184 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
185 } | |
186 } | |
171 } | 187 } |