comparison Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 82:5b127ab0080b

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Dec 2016 17:01:34 +0100
parents d529d9ce3c7e
children 319b8c45c231
comparison
equal deleted inserted replaced
81:d101055fc20b 82:5b127ab0080b
48 #else 48 #else
49 # define ORTHANC_PLUGINS_THROW_EXCEPTION(code) throw ::OrthancPlugins::PluginException(code) 49 # define ORTHANC_PLUGINS_THROW_EXCEPTION(code) throw ::OrthancPlugins::PluginException(code)
50 #endif 50 #endif
51 51
52 52
53 #if (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER >= 2 || \
54 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == 1 && \
55 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER >= 2))
56 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0
57 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 1
58 #else
59 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 0
60 #endif
61
62
63
53 64
54 namespace OrthancPlugins 65 namespace OrthancPlugins
55 { 66 {
56 typedef void (*RestCallback) (OrthancPluginRestOutput* output, 67 typedef void (*RestCallback) (OrthancPluginRestOutput* output,
57 const char* url, 68 const char* url,
170 181
171 void CreateDicom(const Json::Value& tags, 182 void CreateDicom(const Json::Value& tags,
172 OrthancPluginCreateDicomFlags flags); 183 OrthancPluginCreateDicomFlags flags);
173 184
174 void ReadFile(const std::string& path); 185 void ReadFile(const std::string& path);
186
187 void GetDicomQuery(const OrthancPluginWorklistQuery* query);
188
189 void DicomToJson(Json::Value& target,
190 OrthancPluginDicomToJsonFormat format,
191 OrthancPluginDicomToJsonFlags flags,
192 uint32_t maxStringLength);
175 }; 193 };
176 194
177 195
178 class OrthancString : public boost::noncopyable 196 class OrthancString : public boost::noncopyable
179 { 197 {
180 private: 198 private:
181 OrthancPluginContext* context_; 199 OrthancPluginContext* context_;
182 char* str_; 200 char* str_;
183 201
202 void Clear();
203
184 public: 204 public:
185 OrthancString(OrthancPluginContext* context, 205 OrthancString(OrthancPluginContext* context) :
186 char* str); 206 context_(context),
207 str_(NULL)
208 {
209 }
187 210
188 ~OrthancString() 211 ~OrthancString()
189 { 212 {
190 Clear(); 213 Clear();
191 } 214 }
192 215
193 void Clear(); 216 // This transfers ownership, warning: The string must have been
217 // allocated by the Orthanc core
218 void Assign(char* str);
194 219
195 const char* GetContent() const 220 const char* GetContent() const
196 { 221 {
197 return str_; 222 return str_;
198 } 223 }
260 285
261 float GetFloatValue(const std::string& key, 286 float GetFloatValue(const std::string& key,
262 float defaultValue) const; 287 float defaultValue) const;
263 }; 288 };
264 289
265 class OrthancImage 290 class OrthancImage : public boost::noncopyable
266 { 291 {
267 private: 292 private:
268 OrthancPluginContext* context_; 293 OrthancPluginContext* context_;
269 OrthancPluginImage* image_; 294 OrthancPluginImage* image_;
270 295
316 void AnswerPngImage(OrthancPluginRestOutput* output); 341 void AnswerPngImage(OrthancPluginRestOutput* output);
317 342
318 void AnswerJpegImage(OrthancPluginRestOutput* output, 343 void AnswerJpegImage(OrthancPluginRestOutput* output,
319 uint8_t quality); 344 uint8_t quality);
320 }; 345 };
346
347
348 #if HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1
349 class FindMatcher : public boost::noncopyable
350 {
351 private:
352 OrthancPluginContext* context_;
353 OrthancPluginFindMatcher* matcher_;
354 const OrthancPluginWorklistQuery* worklist_;
355
356 void SetupDicom(OrthancPluginContext* context,
357 const void* query,
358 uint32_t size);
359
360 public:
361 FindMatcher(OrthancPluginContext* context,
362 const OrthancPluginWorklistQuery* worklist);
363
364 FindMatcher(OrthancPluginContext* context,
365 const void* query,
366 uint32_t size)
367 {
368 SetupDicom(context, query, size);
369 }
370
371 FindMatcher(OrthancPluginContext* context,
372 const MemoryBuffer& dicom)
373 {
374 SetupDicom(context, dicom.GetData(), dicom.GetSize());
375 }
376
377 ~FindMatcher();
378
379 bool IsMatch(const void* dicom,
380 uint32_t size) const;
381
382 bool IsMatch(const MemoryBuffer& dicom) const
383 {
384 return IsMatch(dicom.GetData(), dicom.GetSize());
385 }
386 };
387 #endif
321 388
322 389
323 bool RestApiGet(Json::Value& result, 390 bool RestApiGet(Json::Value& result,
324 OrthancPluginContext* context, 391 OrthancPluginContext* context,
325 const std::string& uri, 392 const std::string& uri,