GIRAFFE Pipeline Reference Manual

girange.c
1 /*
2  * This file is part of the GIRAFFE Pipeline
3  * Copyright (C) 2002-2019 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 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23 
24 #include <cxmessages.h>
25 #include <cxmemory.h>
26 
27 #include <cpl_error.h>
28 
29 #include "girange.h"
30 
31 
40 struct GiRange {
41  cxdouble min;
42  cxdouble max;
43 };
44 
45 
57 GiRange *
59 {
60 
61  GiRange *self = cx_calloc(1, sizeof *self);
62  return self;
63 
64 }
65 
66 
82 GiRange *
83 giraffe_range_create(cxdouble min, cxdouble max)
84 {
85 
86  const cxchar *fctid = "giraffe_range_create";
87 
88  GiRange *self = NULL;
89 
90 
91  if (min > max) {
92  cpl_error_set(fctid, CPL_ERROR_ILLEGAL_INPUT);
93  return NULL;
94  }
95 
96  self = cx_calloc(1, sizeof *self);
97 
98  self->min = min;
99  self->max = max;
100 
101  return self;
102 
103 }
104 
105 
117 void
118 giraffe_range_delete(GiRange *self)
119 {
120 
121  if (self) {
122  cx_free(self);
123  }
124 
125  return;
126 
127 }
128 
129 
143 void
144 giraffe_range_set_min(GiRange *self, cxdouble min)
145 {
146 
147  cx_assert(self != NULL);
148 
149  self->min = min;
150  return;
151 
152 }
153 
154 
166 cxdouble
167 giraffe_range_get_min(const GiRange *const self)
168 {
169 
170  cx_assert(self != NULL);
171  return self->min;
172 
173 }
174 
175 
189 void
190 giraffe_range_set_max(GiRange *self, cxdouble max)
191 {
192 
193  cx_assert(self != NULL);
194 
195  self->max = max;
196  return;
197 
198 }
199 
200 
212 cxdouble
213 giraffe_range_get_max(const GiRange *const self)
214 {
215 
216  cx_assert(self != NULL);
217  return self->max;
218 
219 }
GiRange * giraffe_range_create(cxdouble min, cxdouble max)
Creates a new range from the given minimum and maximum values.
Definition: girange.c:83
void giraffe_range_set_min(GiRange *self, cxdouble min)
Set the minimum of a range.
Definition: girange.c:144
void giraffe_range_delete(GiRange *self)
Destroys a range object.
Definition: girange.c:118
cxdouble giraffe_range_get_min(const GiRange *const self)
Get the minimum of a range.
Definition: girange.c:167
GiRange * giraffe_range_new(void)
Creates a new range.
Definition: girange.c:58
cxdouble giraffe_range_get_max(const GiRange *const self)
Get the maximum of a range.
Definition: girange.c:213
void giraffe_range_set_max(GiRange *self, cxdouble max)
Set the maximum of a range.
Definition: girange.c:190

This file is part of the GIRAFFE Pipeline Reference Manual 2.16.10.
Documentation copyright © 2002-2006 European Southern Observatory.
Generated on Thu Dec 15 2022 21:18:51 by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2004