31#include "moo_scilist.h"
58 return (moo_scilist *)cpl_calloc(1,
sizeof(moo_scilist));
87 cpl_ensure(self, CPL_ERROR_NULL_INPUT, NULL);
88 cpl_ensure(pos >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
89 cpl_ensure(pos < self->size, CPL_ERROR_ACCESS_OUT_OF_RANGE, NULL);
92 out = self->list[pos];
95 for (i = pos + 1; i < self->size; i++) {
96 self->list[i - 1] = self->list[i];
123 while (self->size > 0) {
124 int i = self->size - 1;
132 if (self->list[i] == del) {
159 cpl_free(self->list);
200 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, -1);
202 assert(self->size >= 0);
242 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
243 cpl_ensure_code(sci, CPL_ERROR_NULL_INPUT);
244 cpl_ensure_code(pos >= 0, CPL_ERROR_ILLEGAL_INPUT);
245 cpl_ensure_code(pos <= self->size, CPL_ERROR_ACCESS_OUT_OF_RANGE);
248 if (pos < self->size && sci == self->list[pos])
249 return CPL_ERROR_NONE;
251 if (pos == self->size) {
254 cpl_realloc(self->list, (
size_t)self->size *
sizeof(moo_sci *));
261 for (i = 0; i < self->size; i++) {
262 if (i != pos && self->list[i] == self->list[pos])
265 if (i == self->size) {
272 self->list[pos] = sci;
274 return CPL_ERROR_NONE;
306 cpl_ensure_code(self, CPL_ERROR_NULL_INPUT);
308 return cpl_error_get_code();
323 cpl_ensure(frameset != NULL, CPL_ERROR_NULL_INPUT, NULL);
326 for (i = 0; i < cpl_frameset_get_size(frameset); ++i) {
327 const cpl_frame *current_frame =
328 cpl_frameset_get_position_const(frameset, i);
347 cpl_ensure(frameset != NULL, CPL_ERROR_NULL_INPUT, NULL);
350 for (i = 0; i < cpl_frameset_get_size(frameset); ++i) {
351 const cpl_frame *current_frame =
352 cpl_frameset_get_position_const(frameset, i);
355 if (target_table != NULL) {
356 int nrow = cpl_table_get_nrow(target_table->table);
386 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
387 cpl_ensure(i >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
389 cpl_ensure(i < size, CPL_ERROR_ILLEGAL_INPUT, NULL);
391 return self->list[i];
411 moo_sci_single *result = NULL;
412 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
413 cpl_ensure(i >= 0, CPL_ERROR_ILLEGAL_INPUT, NULL);
415 cpl_ensure(i < size, CPL_ERROR_ILLEGAL_INPUT, NULL);
417 if (self->list[i] != NULL) {
443 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
446 for (i = 0; i < self->size; i++) {
447 moo_sci *sci = self->list[i];
450 return CPL_ERROR_NONE;
470 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
472 cpl_errorstate prestate = cpl_errorstate_get();
474 hdrl_imagelist *res = NULL;
477 res = hdrl_imagelist_new();
479 for (i = 0; i < self->size; i++) {
480 moo_sci *sci = self->list[i];
481 moo_sci_single *single = NULL;
484 if (single != NULL) {
486 hdrl_imagelist_set(res, img, i);
491 if (!cpl_errorstate_is_equal(prestate)) {
492 cpl_errorstate_dump(prestate, CPL_FALSE, cpl_errorstate_dump_one);
493 hdrl_imagelist_delete(res);
516 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
518 cpl_errorstate prestate = cpl_errorstate_get();
520 cpl_imagelist *res = NULL;
523 res = cpl_imagelist_new();
525 for (i = 0; i < self->size; i++) {
526 moo_sci *sci = self->list[i];
527 moo_sci_single *single = NULL;
530 if (single != NULL) {
532 cpl_imagelist_set(res, qual, i);
537 if (!cpl_errorstate_is_equal(prestate)) {
538 cpl_errorstate_dump(prestate, CPL_FALSE, cpl_errorstate_dump_one);
539 cpl_imagelist_delete(res);
562 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
564 cpl_errorstate prestate = cpl_errorstate_get();
566 cpl_imagelist *res = NULL;
569 res = cpl_imagelist_new();
571 for (i = 0; i < self->size; i++) {
572 moo_sci *sci = self->list[i];
573 moo_sci_single *single = NULL;
576 if (single != NULL) {
578 cpl_imagelist_set(res, sky, i);
583 if (!cpl_errorstate_is_equal(prestate)) {
584 cpl_errorstate_dump(prestate, CPL_FALSE, cpl_errorstate_dump_one);
585 cpl_imagelist_delete(res);
enum _moo_detector_type_ moo_detector_type
The type code type.
cpl_image * moo_sci_single_get_sky(moo_sci_single *self)
Get sky of sci single.
hdrl_image * moo_sci_single_get_image(moo_sci_single *self)
Get image of SCI_SINGLE.
cpl_image * moo_sci_single_get_qual(moo_sci_single *self)
Get image of qual.
moo_sci_single * moo_sci_load_single(moo_sci *self, moo_detector_type type, int level)
Load the type part in SCI and return it.
void moo_sci_delete(moo_sci *self)
Delete a moo_sci.
moo_sci * moo_sci_create(const cpl_frame *frame)
Create a new empty SCI filename.
moo_sci_single * moo_sci_get_single(moo_sci *self, moo_detector_type type)
Get the type part in SCI and return it.
moo_target_table * moo_sci_get_target_table(moo_sci *self)
Get the target table of SCI file.
moo_sci * moo_scilist_get(moo_scilist *self, int i)
Get the SCI at the position i in the list.
moo_sci * moo_scilist_unset(moo_scilist *self, cpl_size pos)
Remove a SCI from a SCI list.
hdrl_imagelist * moo_scilist_get_image(const moo_scilist *self, moo_detector_type type)
Get the all the images of the type part in the scilist.
void moo_scilist_delete(moo_scilist *self)
Free all memory used by a moo_scilist object including the SCI.
cpl_imagelist * moo_scilist_get_qual(const moo_scilist *self, moo_detector_type type)
Get the all the QUAL of the type part in the scilist.
moo_sci_single * moo_scilist_get_single(moo_scilist *self, int i, moo_detector_type type)
Get the SCI SINGLE at the position i in the list for the given detector.
cpl_error_code moo_scilist_load_single(const moo_scilist *self, moo_detector_type type, int level)
Load the type part for all SCI in the scilist.
moo_scilist * moo_scilist_create(cpl_frameset *frameset)
Create a new moo_scilist from the given SCI frameset.
cpl_error_code moo_scilist_set(moo_scilist *self, moo_sci *sci, cpl_size pos)
Insert a SCI into an moo_scilist.
moo_scilist * moo_scilist_create_clean(cpl_frameset *frameset)
Create a new moo_scilist from the given SCI frameset ignoring SCI with 0 targets.
moo_scilist * moo_scilist_new(void)
Create a new moo_scilist.
void moo_scilist_unwrap(moo_scilist *self)
Free memory used by a moo_scilist object, except the SCI.
void moo_scilist_empty(moo_scilist *self)
Empty an moo_scilist and deallocate all its SCI.
cpl_size moo_scilist_get_size(const moo_scilist *self)
Get the number of SCI in the scilist.
cpl_error_code moo_scilist_push(moo_scilist *self, moo_sci *sci)
Insert a SCI a the end of moo_scilist.
cpl_imagelist * moo_scilist_get_sky(const moo_scilist *self, moo_detector_type type)
Get the all the SKY of the type part in the scilist.
the different type of detectors