CR2RE Pipeline Reference Manual 1.6.8
hdrl_parameter.c
1/* $Id: hdrl_parameter.c,v 1.3 2013-10-10 13:47:35 jtaylor Exp $
2 *
3 * This file is part of the HDRL
4 * Copyright (C) 2013 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/*
22 * $Author: jtaylor $
23 * $Date: 2013-10-10 13:47:35 $
24 * $Revision: 1.3 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32/*-----------------------------------------------------------------------------
33 Includes
34 -----------------------------------------------------------------------------*/
35
36#include "hdrl_parameter.h"
37#include "hdrl_parameter_defs.h"
38#include <cpl.h>
39
40#include <stddef.h>
41#include <assert.h>
42
43/*----------------------------------------------------------------------------*/
54/*----------------------------------------------------------------------------*/
55
56/*-----------------------------------------------------------------------------
57 Functions
58 -----------------------------------------------------------------------------*/
59
64/* ---------------------------------------------------------------------------*/
73/* ---------------------------------------------------------------------------*/
74hdrl_parameter * hdrl_parameter_new(const hdrl_parameter_typeobj * typeobj)
75{
76 hdrl_parameter * p = typeobj->fp_alloc(typeobj->obj_size);
77 p->base = typeobj;
78 return p;
79}
80
81/* ---------------------------------------------------------------------------*/
91/* ---------------------------------------------------------------------------*/
92int hdrl_parameter_check_type(const hdrl_parameter * self,
93 const hdrl_parameter_typeobj * type)
94{
95 /* we can't compare the base pointers as they may be different in recipes
96 * and libraries when static linking */
97 if (self) {
98 return ((const hdrl_parameter_typeobj *)self->base)->type == type->type;
99 }
100 else {
101 return 0;
102 }
103}
104
105
106/* ---------------------------------------------------------------------------*/
115/* ---------------------------------------------------------------------------*/
116const hdrl_parameter_typeobj * hdrl_parameter_get_type(const hdrl_parameter * self)
117{
118 return self->base;
119}
120
121/* ---------------------------------------------------------------------------*/
130/* ---------------------------------------------------------------------------*/
131hdrl_parameter_enum
132hdrl_parameter_get_parameter_enum(const hdrl_parameter * self){
133 return hdrl_parameter_get_type(self)->type;
134}
135
138/* ---------------------------------------------------------------------------*/
147/* ---------------------------------------------------------------------------*/
148void hdrl_parameter_delete(hdrl_parameter * obj)
149{
150 if (obj) {
151 obj->base->fp_free(obj);
152 }
153}
154
155/* ---------------------------------------------------------------------------*/
163/* ---------------------------------------------------------------------------*/
164void hdrl_parameter_destroy(hdrl_parameter * obj)
165{
166 if (obj == NULL) {
167 return;
168 }
169
170 if (obj->base->fp_destroy) {
171 obj->base->fp_destroy(obj);
172 }
173 else {
174 obj->base->fp_free(obj);
175 }
176}
177
void hdrl_parameter_destroy(hdrl_parameter *obj)
deep delete of a parameter
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter