31#include "moo_detlist.h"
58 return (moo_detlist *)cpl_calloc(1,
sizeof(moo_detlist));
73 cpl_ensure(frameset != NULL, CPL_ERROR_NULL_INPUT, NULL);
77 for (i = 0; i < cpl_frameset_get_size(frameset); ++i) {
78 const cpl_frame *current_frame =
79 cpl_frameset_get_position_const(frameset, i);
112 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
113 cpl_ensure_code(num >= 1 && num <= 2, CPL_ERROR_ILLEGAL_INPUT);
117 for (i = 0; i < self->size; i++) {
118 moo_det *det = self->list[i];
121 return CPL_ERROR_NONE;
147 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
148 cpl_ensure_code(num >= 1 && num <= 2, CPL_ERROR_ILLEGAL_INPUT);
151 for (i = 0; i < self->size; i++) {
152 moo_det *det = self->list[i];
154 if (status != CPL_ERROR_NONE) {
158 return CPL_ERROR_NONE;
175 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, -1);
177 assert(self->size >= 0);
198 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
199 cpl_ensure(i >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
201 cpl_ensure(i < size, CPL_ERROR_ILLEGAL_INPUT, NULL);
203 return self->list[i];
227 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
228 cpl_ensure(num >= 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
229 cpl_ensure(num <= 2, CPL_ERROR_ACCESS_OUT_OF_RANGE, NULL);
231 cpl_errorstate prestate = cpl_errorstate_get();
233 hdrl_imagelist *res = NULL;
236 res = hdrl_imagelist_new();
238 for (i = 0; i < self->size; i++) {
239 moo_det *det = self->list[i];
240 moo_single *single = NULL;
243 if (single != NULL) {
245 hdrl_imagelist_set(res, img, i);
250 if (!cpl_errorstate_is_equal(prestate)) {
251 cpl_msg_error(__func__,
"Error in detlist");
252 cpl_errorstate_dump(prestate, CPL_FALSE, cpl_errorstate_dump_one);
253 hdrl_imagelist_delete(res);
283 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
284 cpl_ensure(num >= 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
285 cpl_ensure(num <= 2, CPL_ERROR_ACCESS_OUT_OF_RANGE, NULL);
287 cpl_imagelist *res = cpl_imagelist_new();
290 for (i = 0; i < self->size; i++) {
291 moo_det *det = self->list[i];
293 if (single != NULL) {
324 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
325 cpl_ensure(num >= 1, CPL_ERROR_ILLEGAL_INPUT, NULL);
326 cpl_ensure(num <= 2, CPL_ERROR_ACCESS_OUT_OF_RANGE, NULL);
328 cpl_imagelist *res = cpl_imagelist_new();
331 for (i = 0; i < self->size; i++) {
332 moo_det *det = self->list[i];
334 if (single != NULL) {
377 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
378 cpl_ensure_code(det, CPL_ERROR_NULL_INPUT);
379 cpl_ensure_code(pos >= 0, CPL_ERROR_ILLEGAL_INPUT);
380 cpl_ensure_code(pos <= self->size, CPL_ERROR_ACCESS_OUT_OF_RANGE);
383 if (pos < self->size && det == self->list[pos])
384 return CPL_ERROR_NONE;
386 if (pos == self->size) {
389 cpl_realloc(self->list, (
size_t)self->size *
sizeof(moo_det *));
396 for (i = 0; i < self->size; i++) {
397 if (i != pos && self->list[i] == self->list[pos])
400 if (i == self->size) {
407 self->list[pos] = det;
409 return CPL_ERROR_NONE;
441 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
470 cpl_ensure(self, CPL_ERROR_NULL_INPUT, NULL);
471 cpl_ensure(pos >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
472 cpl_ensure(pos < self->size, CPL_ERROR_ACCESS_OUT_OF_RANGE, NULL);
475 out = self->list[pos];
478 for (i = pos + 1; i < self->size; i++) {
479 self->list[i - 1] = self->list[i];
506 while (self->size > 0) {
507 int i = self->size - 1;
515 if (self->list[i] == del) {
542 cpl_free(self->list);
moo_single * moo_det_load_single(moo_det *self, moo_detector_type type, int num, int level)
Load the type part in DET and return it.
cpl_error_code moo_det_free_single(moo_det *self, moo_detector_type type, int num)
Free the given type part in DET.
moo_det * moo_det_create(const cpl_frame *frame)
Create a new moo_det from the given DET frame.
void moo_det_delete(moo_det *self)
Delete a moo_det.
moo_single * moo_det_get_single(moo_det *self, moo_detector_type type, int num)
Get the type part in DET and return it.
enum _moo_detector_type_ moo_detector_type
The type code type.
hdrl_imagelist * moo_detlist_get_image(const moo_detlist *self, moo_detector_type type, int num)
Get the all the images of the type part in the detlist.
cpl_error_code moo_detlist_push(moo_detlist *self, moo_det *det)
Insert a DET a the end of moo_detlist.
moo_detlist * moo_detlist_create(cpl_frameset *frameset)
Create a new moo_detlist from the given DET frameset.
cpl_size moo_detlist_get_size(const moo_detlist *self)
Get the number of DET in the detlist.
moo_det * moo_detlist_unset(moo_detlist *self, cpl_size pos)
Remove a DET from a DET list.
moo_detlist * moo_detlist_new(void)
Create a new moo_detlist.
void moo_detlist_empty(moo_detlist *self)
Empty an moo_detlist and deallocate all its DET.
void moo_detlist_unwrap(moo_detlist *self)
Free memory used by a moo_detlist object, except the DET.
cpl_error_code moo_detlist_free_single(const moo_detlist *self, moo_detector_type type, int num)
Free the type part for all DET in the detlist.
cpl_imagelist * moo_detlist_get_single_data(const moo_detlist *self, moo_detector_type type, int num)
Get the type data part for all DET in the detlist.
cpl_imagelist * moo_detlist_get_single_qual(const moo_detlist *self, moo_detector_type type, int num)
Get the type QUAL part for all DET in the detlist.
cpl_error_code moo_detlist_load_single(const moo_detlist *self, moo_detector_type type, int num, int level)
Load the type part for all DET in the detlist.
void moo_detlist_delete(moo_detlist *self)
Free all memory used by a moo_detlist object including the DET.
moo_det * moo_detlist_get(moo_detlist *self, int i)
Get the DET at the position i in the list.
cpl_error_code moo_detlist_set(moo_detlist *self, moo_det *det, cpl_size pos)
Insert a DET into an moo_detlist.
hdrl_image * moo_single_get_image(moo_single *self)
Get the IMAGE part (DATA,ERR) of single DET.
cpl_image * moo_single_get_data(moo_single *self)
Get the DATA part of single DET.
cpl_image * moo_single_get_qual(moo_single *self)
Get the QUAL part of single DET.