comparison Plugins/OrthancCPlugin/OrthancCPlugin.h @ 904:2732b5f57d9c plugins

sample to forward dicom data
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Jun 2014 16:07:47 +0200
parents 7d88f3f4a3b3
children cbc0ea03dffe
comparison
equal deleted inserted replaced
903:06b9a30f1e6d 904:2732b5f57d9c
122 typedef struct 122 typedef struct
123 { 123 {
124 OrthancPluginHttpMethod method; 124 OrthancPluginHttpMethod method;
125 125
126 /* Groups of the regular expression */ 126 /* Groups of the regular expression */
127 const char* const* groupValues; 127 const char* const* groups;
128 uint32_t groupCount; 128 uint32_t groupsCount;
129 129
130 /* For GET requests */ 130 /* For GET requests */
131 const char* const* getKeys; 131 const char* const* getKeys;
132 const char* const* getValues; 132 const char* const* getValues;
133 uint32_t getCount; 133 uint32_t getCount;
147 /* Registration of callbacks */ 147 /* Registration of callbacks */
148 OrthancPluginService_RegisterRestCallback = 1000, 148 OrthancPluginService_RegisterRestCallback = 1000,
149 149
150 /* Sending answers to REST calls */ 150 /* Sending answers to REST calls */
151 OrthancPluginService_AnswerBuffer = 2000, 151 OrthancPluginService_AnswerBuffer = 2000,
152 OrthancPluginService_CompressAndAnswerPngImage = 2001 152 OrthancPluginService_CompressAndAnswerPngImage = 2001,
153
154 /* Access to the Orthanc database */
155 OrthancPluginService_GetDicomForInstance = 3000
153 } OrthancPluginService; 156 } OrthancPluginService;
154 157
155 158
156 159
157 /** 160 /**
199 **/ 202 **/
200 OrthancPluginPixelFormat_RGBA32 = 5 203 OrthancPluginPixelFormat_RGBA32 = 5
201 } OrthancPluginPixelFormat; 204 } OrthancPluginPixelFormat;
202 205
203 206
207 typedef struct
208 {
209 void* data;
210 uint32_t size;
211 } OrthancPluginMemoryBuffer;
212
213
214
215
204 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput; 216 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput;
205 217
206 typedef int32_t (*OrthancPluginRestCallback) ( 218 typedef int32_t (*OrthancPluginRestCallback) (
207 OrthancPluginRestOutput* output, 219 OrthancPluginRestOutput* output,
208 const char* url, 220 const char* url,
210 222
211 typedef struct _OrthancPluginContext_t 223 typedef struct _OrthancPluginContext_t
212 { 224 {
213 void* pluginsManager; 225 void* pluginsManager;
214 const char* orthancVersion; 226 const char* orthancVersion;
215 void (*FreeBuffer) (void* buffer); 227 void (*Free) (void* buffer);
216 int32_t (*InvokeService) (struct _OrthancPluginContext_t* context, 228 int32_t (*InvokeService) (struct _OrthancPluginContext_t* context,
217 OrthancPluginService service, 229 OrthancPluginService service,
218 const void* params); 230 const void* params);
219 } OrthancPluginContext; 231 } OrthancPluginContext;
220 232
221 233
234 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString(
235 OrthancPluginContext* context,
236 char* str)
237 {
238 context->Free(str);
239 }
240
241
242 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer(
243 OrthancPluginContext* context,
244 OrthancPluginMemoryBuffer* buffer)
245 {
246 context->Free(buffer->data);
247 }
248
249
222 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError( 250 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError(
223 OrthancPluginContext* context, 251 OrthancPluginContext* context,
224 const char* str) 252 const char* str)
225 { 253 {
226 context->InvokeService(context, OrthancPluginService_LogError, str); 254 context->InvokeService(context, OrthancPluginService_LogError, str);
245 273
246 typedef struct 274 typedef struct
247 { 275 {
248 const char* pathRegularExpression; 276 const char* pathRegularExpression;
249 OrthancPluginRestCallback callback; 277 OrthancPluginRestCallback callback;
250 } _OrthancPluginRestCallbackParams; 278 } _OrthancPluginRestCallback;
251 279
252 280
253 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback( 281 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback(
254 OrthancPluginContext* context, 282 OrthancPluginContext* context,
255 const char* pathRegularExpression, 283 const char* pathRegularExpression,
256 OrthancPluginRestCallback callback) 284 OrthancPluginRestCallback callback)
257 { 285 {
258 _OrthancPluginRestCallbackParams params; 286 _OrthancPluginRestCallback params;
259 params.pathRegularExpression = pathRegularExpression; 287 params.pathRegularExpression = pathRegularExpression;
260 params.callback = callback; 288 params.callback = callback;
261 context->InvokeService(context, OrthancPluginService_RegisterRestCallback, &params); 289 context->InvokeService(context, OrthancPluginService_RegisterRestCallback, &params);
262 } 290 }
263 291
266 { 294 {
267 OrthancPluginRestOutput* output; 295 OrthancPluginRestOutput* output;
268 const char* answer; 296 const char* answer;
269 uint32_t answerSize; 297 uint32_t answerSize;
270 const char* mimeType; 298 const char* mimeType;
271 } _OrthancPluginAnswerBufferParams; 299 } _OrthancPluginAnswerBuffer;
272 300
273 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer( 301 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(
274 OrthancPluginContext* context, 302 OrthancPluginContext* context,
275 OrthancPluginRestOutput* output, 303 OrthancPluginRestOutput* output,
276 const char* answer, 304 const char* answer,
277 uint32_t answerSize, 305 uint32_t answerSize,
278 const char* mimeType) 306 const char* mimeType)
279 { 307 {
280 _OrthancPluginAnswerBufferParams params; 308 _OrthancPluginAnswerBuffer params;
281 params.output = output; 309 params.output = output;
282 params.answer = answer; 310 params.answer = answer;
283 params.answerSize = answerSize; 311 params.answerSize = answerSize;
284 params.mimeType = mimeType; 312 params.mimeType = mimeType;
285 context->InvokeService(context, OrthancPluginService_AnswerBuffer, &params); 313 context->InvokeService(context, OrthancPluginService_AnswerBuffer, &params);
292 OrthancPluginPixelFormat format; 320 OrthancPluginPixelFormat format;
293 uint32_t width; 321 uint32_t width;
294 uint32_t height; 322 uint32_t height;
295 uint32_t pitch; 323 uint32_t pitch;
296 const void* buffer; 324 const void* buffer;
297 } _OrthancPluginCompressAndAnswerPngImageParams; 325 } _OrthancPluginCompressAndAnswerPngImage;
298 326
299 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage( 327 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage(
300 OrthancPluginContext* context, 328 OrthancPluginContext* context,
301 OrthancPluginRestOutput* output, 329 OrthancPluginRestOutput* output,
302 OrthancPluginPixelFormat format, 330 OrthancPluginPixelFormat format,
303 uint32_t width, 331 uint32_t width,
304 uint32_t height, 332 uint32_t height,
305 uint32_t pitch, 333 uint32_t pitch,
306 const void* buffer) 334 const void* buffer)
307 { 335 {
308 _OrthancPluginCompressAndAnswerPngImageParams params; 336 _OrthancPluginCompressAndAnswerPngImage params;
309 params.output = output; 337 params.output = output;
310 params.format = format; 338 params.format = format;
311 params.width = width; 339 params.width = width;
312 params.height = height; 340 params.height = height;
313 params.pitch = pitch; 341 params.pitch = pitch;
314 params.buffer = buffer; 342 params.buffer = buffer;
315 context->InvokeService(context, OrthancPluginService_CompressAndAnswerPngImage, &params); 343 context->InvokeService(context, OrthancPluginService_CompressAndAnswerPngImage, &params);
316 } 344 }
317 345
318 346
347 typedef struct
348 {
349 OrthancPluginMemoryBuffer* target;
350 const char* instanceId;
351 } _OrthancPluginGetDicomForInstance;
352
353 ORTHANC_PLUGIN_INLINE int OrthancPluginGetDicomForInstance(
354 OrthancPluginContext* context,
355 OrthancPluginMemoryBuffer* target,
356 const char* instanceId)
357 {
358 _OrthancPluginGetDicomForInstance params;
359 params.target = target;
360 params.instanceId = instanceId;
361 return context->InvokeService(context, OrthancPluginService_GetDicomForInstance, &params);
362 }
363
319 364
320 /** 365 /**
321 Each plugin must define 4 functions, whose signature are: 366 Each plugin must define 4 functions, whose signature are:
322 - int32_t OrthancPluginInitialize(const OrthancPluginContext*); 367 - int32_t OrthancPluginInitialize(const OrthancPluginContext*);
323 - void OrthancPluginFinalize(); 368 - void OrthancPluginFinalize();