comparison Plugins/OrthancCPlugin/OrthancCPlugin.h @ 1135:67c3c1e4a6e0

index-only mode, and custom storage area with plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Sep 2014 15:55:43 +0200
parents a91b4900f06a
children 208dc67b9bab
comparison
equal deleted inserted replaced
1134:ba9fd42284d0 1135:67c3c1e4a6e0
13 * ::OrthancPluginCheckVersion(). 13 * ::OrthancPluginCheckVersion().
14 * - Store the context pointer so that it can use the plugin 14 * - Store the context pointer so that it can use the plugin
15 * services of Orthanc. 15 * services of Orthanc.
16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). 16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback().
17 * - Register all its callbacks for received instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). 17 * - Register all its callbacks for received instances using ::OrthancPluginRegisterOnStoredInstanceCallback().
18 * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea().
18 * -# <tt>void OrthancPluginFinalize()</tt>: 19 * -# <tt>void OrthancPluginFinalize()</tt>:
19 * This function is invoked by Orthanc during its shutdown. The plugin 20 * This function is invoked by Orthanc during its shutdown. The plugin
20 * must free all its memory. 21 * must free all its memory.
21 * -# <tt>const char* OrthancPluginGetName()</tt>: 22 * -# <tt>const char* OrthancPluginGetName()</tt>:
22 * The plugin must return a short string to identify itself. 23 * The plugin must return a short string to identify itself.
85 #define ORTHANC_PLUGINS_API 86 #define ORTHANC_PLUGINS_API
86 #endif 87 #endif
87 88
88 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 0 89 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 0
89 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 8 90 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 8
90 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 1 91 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 3
91 92
92 93
93 94
94 /******************************************************************** 95 /********************************************************************
95 ** Check that function inlining is properly supported. The use of 96 ** Check that function inlining is properly supported. The use of
238 _OrthancPluginService_LogError = 3, 239 _OrthancPluginService_LogError = 3,
239 240
240 /* Registration of callbacks */ 241 /* Registration of callbacks */
241 _OrthancPluginService_RegisterRestCallback = 1000, 242 _OrthancPluginService_RegisterRestCallback = 1000,
242 _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, 243 _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001,
244 _OrthancPluginService_RegisterStorageArea = 1002,
243 245
244 /* Sending answers to REST calls */ 246 /* Sending answers to REST calls */
245 _OrthancPluginService_AnswerBuffer = 2000, 247 _OrthancPluginService_AnswerBuffer = 2000,
246 _OrthancPluginService_CompressAndAnswerPngImage = 2001, 248 _OrthancPluginService_CompressAndAnswerPngImage = 2001,
247 _OrthancPluginService_Redirect = 2002, 249 _OrthancPluginService_Redirect = 2002,
319 **/ 321 **/
320 OrthancPluginPixelFormat_RGBA32 = 5 322 OrthancPluginPixelFormat_RGBA32 = 5
321 } OrthancPluginPixelFormat; 323 } OrthancPluginPixelFormat;
322 324
323 325
326
327 /**
328 * The content types that are supported by Orthanc plugins.
329 **/
330 typedef enum
331 {
332 OrthancPluginContentType_Unknown = 0, /*!< Unknown content type */
333 OrthancPluginContentType_Dicom = 1, /*!< DICOM */
334 OrthancPluginContentType_DicomAsJson = 2 /*!< JSON summary of a DICOM file */
335 } OrthancPluginContentType;
336
337
338
324 /** 339 /**
325 * @brief A memory buffer allocated by the core system of Orthanc. 340 * @brief A memory buffer allocated by the core system of Orthanc.
326 * 341 *
327 * A memory buffer allocated by the core system of Orthanc. When the 342 * A memory buffer allocated by the core system of Orthanc. When the
328 * content of the buffer is not useful anymore, it must be free by a 343 * content of the buffer is not useful anymore, it must be free by a
376 const char* instanceId); 391 const char* instanceId);
377 392
378 393
379 394
380 /** 395 /**
396 * @brief Signature of a function to free dynamic memory.
397 **/
398 typedef void (*OrthancPluginFree) (void* buffer);
399
400
401
402 /**
403 * @brief Callback for writing to the storage area.
404 *
405 * Signature of a callback function that is triggered when Orthanc writes a file to the storage area.
406 *
407 * @param uuid The UUID of the file.
408 * @param content The content of the file.
409 * @param size The size of the file.
410 * @param type The content type corresponding to this file.
411 * @return 0 if success, other value if error.
412 **/
413 typedef int32_t (*OrthancPluginStorageCreate) (
414 const char* uuid,
415 const void* content,
416 int64_t size,
417 OrthancPluginContentType type);
418
419
420
421 /**
422 * @brief Callback for reading from the storage area.
423 *
424 * Signature of a callback function that is triggered when Orthanc reads a file from the storage area.
425 *
426 * @param content The content of the file (output).
427 * @param size The size of the file (output).
428 * @param uuid The UUID of the file of interest.
429 * @param type The content type corresponding to this file.
430 * @return 0 if success, other value if error.
431 **/
432 typedef int32_t (*OrthancPluginStorageRead) (
433 void** content,
434 int64_t* size,
435 const char* uuid,
436 OrthancPluginContentType type);
437
438
439
440 /**
441 * @brief Callback for removing a file from the storage area.
442 *
443 * Signature of a callback function that is triggered when Orthanc deletes a file from the storage area.
444 *
445 * @param uuid The UUID of the file to be removed.
446 * @param type The content type corresponding to this file.
447 * @return 0 if success, other value if error.
448 **/
449 typedef int32_t (*OrthancPluginStorageRemove) (
450 const char* uuid,
451 OrthancPluginContentType type);
452
453
454
455 /**
381 * @brief Opaque structure that contains information about the Orthanc core. 456 * @brief Opaque structure that contains information about the Orthanc core.
382 **/ 457 **/
383 typedef struct _OrthancPluginContext_t 458 typedef struct _OrthancPluginContext_t
384 { 459 {
385 void* pluginsManager; 460 void* pluginsManager;
386 const char* orthancVersion; 461 const char* orthancVersion;
387 void (*Free) (void* buffer); 462 OrthancPluginFree Free;
388 int32_t (*InvokeService) (struct _OrthancPluginContext_t* context, 463 int32_t (*InvokeService) (struct _OrthancPluginContext_t* context,
389 _OrthancPluginService service, 464 _OrthancPluginService service,
390 const void* params); 465 const void* params);
391 } OrthancPluginContext; 466 } OrthancPluginContext;
392 467
393 468
394 469
395 /** 470 /**
1402 } 1477 }
1403 } 1478 }
1404 1479
1405 1480
1406 1481
1482 typedef struct
1483 {
1484 OrthancPluginStorageCreate create_;
1485 OrthancPluginStorageRead read_;
1486 OrthancPluginStorageRemove remove_;
1487 OrthancPluginFree free_;
1488 } _OrthancPluginRegisterStorageArea;
1489
1490 /**
1491 * @brief Register a custom storage area.
1492 *
1493 * This function registers a custom storage area, to replace the
1494 * built-in way Orthanc stores its files on the filesystem. This
1495 * function must be called during the initialization of the plugin,
1496 * i.e. inside the OrthancPluginInitialize() public function.
1497 *
1498 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
1499 * @param
1500 **/
1501 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea(
1502 OrthancPluginContext* context,
1503 OrthancPluginStorageCreate create,
1504 OrthancPluginStorageRead read,
1505 OrthancPluginStorageRemove remove)
1506 {
1507 _OrthancPluginRegisterStorageArea params;
1508 params.create_ = create;
1509 params.read_ = read;
1510 params.remove_ = remove;
1511 params.free_ = free;
1512 context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, &params);
1513 }
1514
1515
1407 #ifdef __cplusplus 1516 #ifdef __cplusplus
1408 } 1517 }
1409 #endif 1518 #endif
1410 1519
1411 1520