comparison OrthancServer/Sources/Database/FindResponse.h @ 5568:b0b5546f1b9f find-refactoring

find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
author Alain Mazy <am@orthanc.team>
date Thu, 25 Apr 2024 09:22:07 +0200
parents def06a42e5ef
children 5a13483d12c5
comparison
equal deleted inserted replaced
5567:f3562c1a150d 5568:b0b5546f1b9f
37 namespace Orthanc 37 namespace Orthanc
38 { 38 {
39 class FindResponse : public boost::noncopyable 39 class FindResponse : public boost::noncopyable
40 { 40 {
41 public: 41 public:
42
43 // TODO-FIND: does it actually make sense to retrieve revisions for metadata and attachments ?
42 class StringWithRevision 44 class StringWithRevision
43 { 45 {
44 private: 46 private:
45 std::string value_; 47 std::string value_;
46 int64_t revision_; 48 int64_t revision_;
78 class Item : public boost::noncopyable 80 class Item : public boost::noncopyable
79 { 81 {
80 private: 82 private:
81 FindRequest::ResponseContent responseContent_; // what has been requested 83 FindRequest::ResponseContent responseContent_; // what has been requested
82 ResourceType level_; 84 ResourceType level_;
83 OrthancIdentifiers identifiers_; 85 std::string resourceId_;
86 std::string parent_;
87 OrthancIdentifiers identifiers_; // TODO-FIND: not convenient to use here. A simple resourceId seems enough
84 std::unique_ptr<DicomMap> dicomMap_; 88 std::unique_ptr<DicomMap> dicomMap_;
85 std::list<std::string> children_; 89 std::list<std::string> children_;
86 std::string childInstanceId_; 90 std::string childInstanceId_;
87 std::list<std::string> labels_; 91 std::set<std::string> labels_;
88 std::map<MetadataType, StringWithRevision> metadata_; 92 std::map<MetadataType, std::string> metadata_;
89 std::map<uint16_t, StringWithRevision> attachments_; 93 std::map<uint16_t, std::string> attachments_;
90 94
91 public: 95 public:
92 Item(FindRequest::ResponseContent responseContent, 96 Item(FindRequest::ResponseContent responseContent,
93 ResourceType level, 97 ResourceType level,
94 const OrthancIdentifiers& identifiers) : 98 const OrthancIdentifiers& identifiers) :
98 { 102 {
99 } 103 }
100 104
101 Item(FindRequest::ResponseContent responseContent, 105 Item(FindRequest::ResponseContent responseContent,
102 ResourceType level, 106 ResourceType level,
107 const std::string& resourceId) :
108 responseContent_(responseContent),
109 level_(level),
110 resourceId_(resourceId)
111 {
112 }
113
114 Item(FindRequest::ResponseContent responseContent,
115 ResourceType level,
103 DicomMap* dicomMap /* takes ownership */); 116 DicomMap* dicomMap /* takes ownership */);
104 117
105 ResourceType GetLevel() const 118 ResourceType GetLevel() const
106 { 119 {
107 return level_; 120 return level_;
108 } 121 }
109 122
123 const std::string& GetResourceId() const
124 {
125 return resourceId_;
126 }
127
110 const OrthancIdentifiers& GetIdentifiers() const 128 const OrthancIdentifiers& GetIdentifiers() const
111 { 129 {
112 return identifiers_; 130 return identifiers_;
113 } 131 }
114 132
133 FindRequest::ResponseContent GetResponseContent() const
134 {
135 return responseContent_;
136 }
137
138 bool HasResponseContent(FindRequest::ResponseContent content) const
139 {
140 return (responseContent_ & content) == content;
141 }
142
143 void AddDicomTag(uint16_t group, uint16_t element, const std::string& value, bool isBinary);
144
115 void AddMetadata(MetadataType metadata, 145 void AddMetadata(MetadataType metadata,
116 const std::string& value, 146 const std::string& value);
117 int64_t revision); 147 //int64_t revision);
148
149 const std::map<MetadataType, std::string>& GetMetadata() const
150 {
151 return metadata_;
152 }
118 153
119 bool HasMetadata(MetadataType metadata) const 154 bool HasMetadata(MetadataType metadata) const
120 { 155 {
121 return metadata_.find(metadata) != metadata_.end(); 156 return metadata_.find(metadata) != metadata_.end();
122 } 157 }
123 158
124 bool LookupMetadata(std::string& value, int64_t revision, 159 bool LookupMetadata(std::string& value, /* int64_t revision, */
125 MetadataType metadata) const; 160 MetadataType metadata) const;
126 161
127 void ListMetadata(std::set<MetadataType>& metadata) const; 162 void ListMetadata(std::set<MetadataType>& metadata) const;
128 163
129 bool HasDicomMap() const 164 bool HasDicomMap() const
131 return dicomMap_.get() != NULL; 166 return dicomMap_.get() != NULL;
132 } 167 }
133 168
134 const DicomMap& GetDicomMap() const; 169 const DicomMap& GetDicomMap() const;
135 170
136 171 void AddChild(const std::string& childId);
137 // TODO: add other getters and setters 172
173 const std::list<std::string>& GetChildren() const
174 {
175 return children_;
176 }
177
178 void SetParent(const std::string& parent)
179 {
180 parent_ = parent;
181 }
182
183 const std::string& GetParent() const
184 {
185 return parent_;
186 }
187
188 void AddLabel(const std::string& label)
189 {
190 labels_.insert(label);
191 }
192
193 const std::set<std::string>& GetLabels() const
194 {
195 return labels_;
196 }
197 // TODO-FIND: add other getters and setters
138 }; 198 };
139 199
140 private: 200 private:
141 std::deque<Item*> items_; 201 std::deque<Item*> items_;
142 202