Mercurial > hg > orthanc
comparison Plugins/OrthancCPlugin/OrthancCPlugin.h @ 901:7d88f3f4a3b3 plugins
refactoring IsServedUri, answer PNG images, regular expression groups
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Jun 2014 15:22:13 +0200 |
parents | 1b92ce45cc8d |
children | 2732b5f57d9c |
comparison
equal
deleted
inserted
replaced
900:1b92ce45cc8d | 901:7d88f3f4a3b3 |
---|---|
121 | 121 |
122 typedef struct | 122 typedef struct |
123 { | 123 { |
124 OrthancPluginHttpMethod method; | 124 OrthancPluginHttpMethod method; |
125 | 125 |
126 /* Groups of the regular expression */ | |
127 const char* const* groupValues; | |
128 uint32_t groupCount; | |
129 | |
126 /* For GET requests */ | 130 /* For GET requests */ |
127 const char* const* getKeys; | 131 const char* const* getKeys; |
128 const char* const* getValues; | 132 const char* const* getValues; |
129 uint32_t getCount; | 133 uint32_t getCount; |
130 | 134 |
142 | 146 |
143 /* Registration of callbacks */ | 147 /* Registration of callbacks */ |
144 OrthancPluginService_RegisterRestCallback = 1000, | 148 OrthancPluginService_RegisterRestCallback = 1000, |
145 | 149 |
146 /* Sending answers to REST calls */ | 150 /* Sending answers to REST calls */ |
147 OrthancPluginService_AnswerBuffer = 2000 | 151 OrthancPluginService_AnswerBuffer = 2000, |
152 OrthancPluginService_CompressAndAnswerPngImage = 2001 | |
148 } OrthancPluginService; | 153 } OrthancPluginService; |
149 | 154 |
150 | 155 |
156 | |
157 /** | |
158 * The memory layout of the pixels of an image. | |
159 **/ | |
160 typedef enum | |
161 { | |
162 /** | |
163 * @brief Graylevel 8bpp image. | |
164 * | |
165 * The image is graylevel. Each pixel is unsigned and stored in | |
166 * one byte. | |
167 **/ | |
168 OrthancPluginPixelFormat_Grayscale8 = 1, | |
169 | |
170 /** | |
171 * @brief Graylevel, unsigned 16bpp image. | |
172 * | |
173 * The image is graylevel. Each pixel is unsigned and stored in | |
174 * two bytes. | |
175 **/ | |
176 OrthancPluginPixelFormat_Grayscale16 = 2, | |
177 | |
178 /** | |
179 * @brief Graylevel, signed 16bpp image. | |
180 * | |
181 * The image is graylevel. Each pixel is signed and stored in two | |
182 * bytes. | |
183 **/ | |
184 OrthancPluginPixelFormat_SignedGrayscale16 = 3, | |
185 | |
186 /** | |
187 * @brief Color image in RGB24 format. | |
188 * | |
189 * This format describes a color image. The pixels are stored in 3 | |
190 * consecutive bytes. The memory layout is RGB. | |
191 **/ | |
192 OrthancPluginPixelFormat_RGB24 = 4, | |
193 | |
194 /** | |
195 * @brief Color image in RGBA32 format. | |
196 * | |
197 * This format describes a color image. The pixels are stored in 4 | |
198 * consecutive bytes. The memory layout is RGBA. | |
199 **/ | |
200 OrthancPluginPixelFormat_RGBA32 = 5 | |
201 } OrthancPluginPixelFormat; | |
151 | 202 |
152 | 203 |
153 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput; | 204 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput; |
154 | 205 |
155 typedef int32_t (*OrthancPluginRestCallback) ( | 206 typedef int32_t (*OrthancPluginRestCallback) ( |
166 OrthancPluginService service, | 217 OrthancPluginService service, |
167 const void* params); | 218 const void* params); |
168 } OrthancPluginContext; | 219 } OrthancPluginContext; |
169 | 220 |
170 | 221 |
222 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError( | |
223 OrthancPluginContext* context, | |
224 const char* str) | |
225 { | |
226 context->InvokeService(context, OrthancPluginService_LogError, str); | |
227 } | |
228 | |
229 | |
230 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning( | |
231 OrthancPluginContext* context, | |
232 const char* str) | |
233 { | |
234 context->InvokeService(context, OrthancPluginService_LogWarning, str); | |
235 } | |
236 | |
237 | |
238 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo( | |
239 OrthancPluginContext* context, | |
240 const char* str) | |
241 { | |
242 context->InvokeService(context, OrthancPluginService_LogInfo, str); | |
243 } | |
244 | |
245 | |
171 typedef struct | 246 typedef struct |
172 { | 247 { |
173 const char* pathRegularExpression; | 248 const char* pathRegularExpression; |
174 OrthancPluginRestCallback callback; | 249 OrthancPluginRestCallback callback; |
175 } _OrthancPluginRestCallbackParams; | 250 } _OrthancPluginRestCallbackParams; |
251 | |
252 | |
253 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback( | |
254 OrthancPluginContext* context, | |
255 const char* pathRegularExpression, | |
256 OrthancPluginRestCallback callback) | |
257 { | |
258 _OrthancPluginRestCallbackParams params; | |
259 params.pathRegularExpression = pathRegularExpression; | |
260 params.callback = callback; | |
261 context->InvokeService(context, OrthancPluginService_RegisterRestCallback, ¶ms); | |
262 } | |
176 | 263 |
177 | 264 |
178 typedef struct | 265 typedef struct |
179 { | 266 { |
180 OrthancPluginRestOutput* output; | 267 OrthancPluginRestOutput* output; |
181 const char* answer; | 268 const char* answer; |
182 uint32_t answerSize; | 269 uint32_t answerSize; |
183 const char* mimeType; | 270 const char* mimeType; |
184 } _OrthancPluginAnswerBufferParams; | 271 } _OrthancPluginAnswerBufferParams; |
185 | |
186 | |
187 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError( | |
188 OrthancPluginContext* context, | |
189 const char* str) | |
190 { | |
191 context->InvokeService(context, OrthancPluginService_LogError, str); | |
192 } | |
193 | |
194 | |
195 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning( | |
196 OrthancPluginContext* context, | |
197 const char* str) | |
198 { | |
199 context->InvokeService(context, OrthancPluginService_LogWarning, str); | |
200 } | |
201 | |
202 | |
203 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo( | |
204 OrthancPluginContext* context, | |
205 const char* str) | |
206 { | |
207 context->InvokeService(context, OrthancPluginService_LogInfo, str); | |
208 } | |
209 | |
210 | |
211 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback( | |
212 OrthancPluginContext* context, | |
213 const char* pathRegularExpression, | |
214 OrthancPluginRestCallback callback) | |
215 { | |
216 _OrthancPluginRestCallbackParams params; | |
217 params.pathRegularExpression = pathRegularExpression; | |
218 params.callback = callback; | |
219 context->InvokeService(context, OrthancPluginService_RegisterRestCallback, ¶ms); | |
220 } | |
221 | |
222 | 272 |
223 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer( | 273 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer( |
224 OrthancPluginContext* context, | 274 OrthancPluginContext* context, |
225 OrthancPluginRestOutput* output, | 275 OrthancPluginRestOutput* output, |
226 const char* answer, | 276 const char* answer, |
234 params.mimeType = mimeType; | 284 params.mimeType = mimeType; |
235 context->InvokeService(context, OrthancPluginService_AnswerBuffer, ¶ms); | 285 context->InvokeService(context, OrthancPluginService_AnswerBuffer, ¶ms); |
236 } | 286 } |
237 | 287 |
238 | 288 |
289 typedef struct | |
290 { | |
291 OrthancPluginRestOutput* output; | |
292 OrthancPluginPixelFormat format; | |
293 uint32_t width; | |
294 uint32_t height; | |
295 uint32_t pitch; | |
296 const void* buffer; | |
297 } _OrthancPluginCompressAndAnswerPngImageParams; | |
298 | |
299 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage( | |
300 OrthancPluginContext* context, | |
301 OrthancPluginRestOutput* output, | |
302 OrthancPluginPixelFormat format, | |
303 uint32_t width, | |
304 uint32_t height, | |
305 uint32_t pitch, | |
306 const void* buffer) | |
307 { | |
308 _OrthancPluginCompressAndAnswerPngImageParams params; | |
309 params.output = output; | |
310 params.format = format; | |
311 params.width = width; | |
312 params.height = height; | |
313 params.pitch = pitch; | |
314 params.buffer = buffer; | |
315 context->InvokeService(context, OrthancPluginService_CompressAndAnswerPngImage, ¶ms); | |
316 } | |
317 | |
318 | |
239 | 319 |
240 /** | 320 /** |
241 Each plugin must define 4 functions, whose signature are: | 321 Each plugin must define 4 functions, whose signature are: |
242 - int32_t OrthancPluginInitialize(const OrthancPluginContext*); | 322 - int32_t OrthancPluginInitialize(const OrthancPluginContext*); |
243 - void OrthancPluginFinalize(); | 323 - void OrthancPluginFinalize(); |