31#include "moo_rbnlist.h"
58 return (moo_rbnlist *)cpl_calloc(1,
sizeof(moo_rbnlist));
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);
108 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
112 for (i = 0; i < self->size; i++) {
113 moo_rbn *rbn = self->list[i];
116 return CPL_ERROR_NONE;
139 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
142 for (i = 0; i < self->size; i++) {
143 moo_rbn *rbn = self->list[i];
145 if (status != CPL_ERROR_NONE) {
149 return CPL_ERROR_NONE;
165 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, -1);
167 assert(self->size >= 0);
188 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
189 cpl_ensure(i >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
191 cpl_ensure(i < size, CPL_ERROR_ILLEGAL_INPUT, NULL);
193 return self->list[i];
214 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
216 cpl_errorstate prestate = cpl_errorstate_get();
218 hdrl_imagelist *res = NULL;
221 res = hdrl_imagelist_new();
223 for (i = 0; i < self->size; i++) {
224 moo_rbn *rbn = self->list[i];
225 moo_rbn_single *single = NULL;
228 if (single != NULL) {
230 hdrl_imagelist_set(res, img, i);
235 if (!cpl_errorstate_is_equal(prestate)) {
236 cpl_msg_error(__func__,
"Error in rbnlist");
237 cpl_errorstate_dump(prestate, CPL_FALSE, cpl_errorstate_dump_one);
238 hdrl_imagelist_delete(res);
262 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
264 cpl_imagelist *res = cpl_imagelist_new();
267 for (i = 0; i < self->size; i++) {
268 moo_rbn *rbn = self->list[i];
270 if (single != NULL) {
296 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
298 cpl_imagelist *res = cpl_imagelist_new();
301 for (i = 0; i < self->size; i++) {
302 moo_rbn *rbn = self->list[i];
304 if (single != NULL) {
347 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
348 cpl_ensure_code(rbn, CPL_ERROR_NULL_INPUT);
349 cpl_ensure_code(pos >= 0, CPL_ERROR_ILLEGAL_INPUT);
350 cpl_ensure_code(pos <= self->size, CPL_ERROR_ACCESS_OUT_OF_RANGE);
353 if (pos < self->size && rbn == self->list[pos])
354 return CPL_ERROR_NONE;
356 if (pos == self->size) {
359 cpl_realloc(self->list, (
size_t)self->size *
sizeof(moo_rbn *));
366 for (i = 0; i < self->size; i++) {
367 if (i != pos && self->list[i] == self->list[pos])
370 if (i == self->size) {
377 self->list[pos] = rbn;
379 return CPL_ERROR_NONE;
411 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
440 cpl_ensure(self, CPL_ERROR_NULL_INPUT, NULL);
441 cpl_ensure(pos >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
442 cpl_ensure(pos < self->size, CPL_ERROR_ACCESS_OUT_OF_RANGE, NULL);
445 out = self->list[pos];
448 for (i = pos + 1; i < self->size; i++) {
449 self->list[i - 1] = self->list[i];
476 while (self->size > 0) {
477 int i = self->size - 1;
485 if (self->list[i] == del) {
512 cpl_free(self->list);
enum _moo_detector_type_ moo_detector_type
The type code type.
cpl_error_code moo_rbnlist_free_single(const moo_rbnlist *self, moo_detector_type type)
Free the type part for all DET in the detlist.
hdrl_image * moo_rbn_single_get_image(moo_rbn_single *self)
Get image of RBN_SINGLE.
cpl_image * moo_rbn_single_get_data(moo_rbn_single *self)
Get image of data.
cpl_image * moo_rbn_single_get_qual(moo_rbn_single *self)
Get image of qual.
moo_rbn_single * moo_rbn_load_single(moo_rbn *self, moo_detector_type type, unsigned int level)
Load the type part in RBN and return it.
void moo_rbn_delete(moo_rbn *self)
Delete a moo_rbn.
moo_rbn_single * moo_rbn_get_single(moo_rbn *self, moo_detector_type type)
Get a RBN single from RBN.
moo_rbn * moo_rbn_create(const cpl_frame *frame)
Create a new empty RBN filename.
cpl_error_code moo_rbn_free_single(moo_rbn *self, moo_detector_type type)
Free the given type part in RBN.
void moo_rbnlist_delete(moo_rbnlist *self)
Free all memory used by a moo_rbnlist object including the RBN.
moo_rbnlist * moo_rbnlist_new(void)
Create a new moo_rbnlist.
cpl_size moo_rbnlist_get_size(const moo_rbnlist *self)
Get the number of RBN in the rbnlist.
void moo_rbnlist_empty(moo_rbnlist *self)
Empty an moo_rbnlist and deallocate all its RBN.
cpl_error_code moo_rbnlist_load_single(const moo_rbnlist *self, moo_detector_type type, int level)
Load the type part for all RBN in the rbnlist.
cpl_error_code moo_rbnlist_push(moo_rbnlist *self, moo_rbn *rbn)
Insert a RBN a the end of moo_rbnlist.
void moo_rbnlist_unwrap(moo_rbnlist *self)
Free memory used by a moo_rbnlist object, except the RBN.
moo_rbnlist * moo_rbnlist_create(const cpl_frameset *frameset)
Create a new moo_rbnlist from the given RBN frameset.
cpl_imagelist * moo_rbnlist_get_single_data(const moo_rbnlist *self, moo_detector_type type)
Get the type data part for all RBN in the rbnlist.
moo_rbn * moo_rbnlist_unset(moo_rbnlist *self, cpl_size pos)
Remove a RBN from a RBN list.
hdrl_imagelist * moo_rbnlist_get_image(const moo_rbnlist *self, moo_detector_type type)
Get the all the images of the type part in the rbnlist.
cpl_imagelist * moo_rbnlist_get_single_qual(const moo_rbnlist *self, moo_detector_type type)
Get the type QUAL part for all RBN in the rbnlist.
cpl_error_code moo_rbnlist_set(moo_rbnlist *self, moo_rbn *rbn, cpl_size pos)
Insert a RBN into an moo_rbnlist.
moo_rbn * moo_rbnlist_get(moo_rbnlist *self, int i)
Get the RBN at the position i in the list.