CR2RE Pipeline Reference Manual 1.6.10
hdrl_parameter.h
1/*
2 * This file is part of the HDRL
3 * Copyright (C) 2013 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef HDRL_PARAMETER_H
21#define HDRL_PARAMETER_H
22
23/*-----------------------------------------------------------------------------
24 New types
25 -----------------------------------------------------------------------------*/
26
27typedef struct _hdrl_parameter_ hdrl_parameter;
28
29/*-----------------------------------------------------------------------------
30 Includes
31 -----------------------------------------------------------------------------*/
32
33#include "hdrl_types.h"
34#include "hdrl_utils.h"
35#include <cpl.h>
36
37CPL_BEGIN_DECLS
38
39/*-----------------------------------------------------------------------------
40 Functions
41 -----------------------------------------------------------------------------*/
42
43void hdrl_parameter_delete(hdrl_parameter * obj);
44void hdrl_parameter_destroy(hdrl_parameter * obj);
45
46/*-----------------------------------------------------------------------------
47 Private declarations - must not be used outside of hdrl
48 -----------------------------------------------------------------------------*/
49#ifdef HDRL_USE_PRIVATE
50
55typedef enum {
56 HDRL_PARAMETER_COLLAPSE_MEAN,
57 HDRL_PARAMETER_COLLAPSE_MEDIAN,
58 HDRL_PARAMETER_COLLAPSE_WEIGHTED_MEAN,
59 HDRL_PARAMETER_COLLAPSE_SIGCLIP,
60 HDRL_PARAMETER_COLLAPSE_MINMAX,
61 HDRL_PARAMETER_COLLAPSE_MODE,
62 HDRL_PARAMETER_RECT_REGION,
63 HDRL_PARAMETER_OVERSCAN,
64 HDRL_PARAMETER_BPM_2D,
65 HDRL_PARAMETER_BPM_3D,
66 HDRL_PARAMETER_BPM_FIT,
67 HDRL_PARAMETER_LACOSMIC,
68 HDRL_PARAMETER_STREHL,
69 HDRL_PARAMETER_FLAT,
70 HDRL_PARAMETER_CATALOGUE,
71 HDRL_PARAMETER_SPECTRUM1D_RESAMPLE_INTERPOLATE,
72 HDRL_PARAMETER_SPECTRUM1D_RESAMPLE_FIT,
73 HDRL_PARAMETER_SPECTRUM1D_RESAMPLE_INTEGRATE,
74 HDRL_PARAMETER_SPECTRUM1D_SHIFT,
75 HDRL_PARAMETER_EFFICIENCY,
76 HDRL_PARAMETER_RESPONSE_TELLURIC_EVALUATION,
77 HDRL_PARAMETER_RESPONSE_FIT,
78 HDRL_PARAMETER_DAR,
79 HDRL_PARAMETER_RESAMPLE_OUTGRID,
80 HDRL_PARAMETER_RESAMPLE_METHOD
81} hdrl_parameter_enum;
82
83
84/* ---------------------------------------------------------------------------*/
93/* ---------------------------------------------------------------------------*/
94#define HDRL_PARAMETER_HEAD void * base
95
96/* ---------------------------------------------------------------------------*/
108/* ---------------------------------------------------------------------------*/
109typedef struct {
110 /* enum defining type */
111 hdrl_parameter_enum type;
112 /* base parameter structure allocation, e.g. cpl_malloc */
113 hdrl_alloc * fp_alloc;
114 /* shallow destructor of the parameter */
115 hdrl_free * fp_free;
116 /* deep destructor of the parameter, deletes all childs
117 * may be NULL in which case fp_free is used */
118 hdrl_free * fp_destroy;
119 /* size of the base parameter structure, argument to fp_alloc */
120 size_t obj_size;
121} hdrl_parameter_typeobj;
122
123
124/* empty parameter, e.g. for collapse_mean */
125typedef struct {
126 HDRL_PARAMETER_HEAD;
127} hdrl_parameter_empty;
128
129hdrl_parameter *
130hdrl_parameter_new(const hdrl_parameter_typeobj * typeobj);
131
132const hdrl_parameter_typeobj *
133hdrl_parameter_get_type(const hdrl_parameter * self);
134
135hdrl_parameter_enum
136hdrl_parameter_get_parameter_enum(const hdrl_parameter * self);
137
138int
139hdrl_parameter_check_type(const hdrl_parameter * self,
140 const hdrl_parameter_typeobj * type);
141
142/* create a singleton parameter which does not need allocating or deleting a
143 * comon use case are enum like parameters */
144#define HDRL_PARAMETER_SINGLETON(name, type, alloc) \
145hdrl_parameter * name = &(hdrl_parameter){ &type }; \
146static void * alloc(size_t HDRL_UNUSED(n)) \
147{ \
148 return name; \
149}
150
151#endif
152
153CPL_END_DECLS
154
155#endif
void hdrl_parameter_destroy(hdrl_parameter *obj)
deep delete of a parameter
CPL_BEGIN_DECLS void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter