girange.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 # include <config.h>
00030 #endif
00031
00032 #include <cxmessages.h>
00033 #include <cxmemory.h>
00034
00035 #include <cpl_error.h>
00036
00037 #include "girange.h"
00038
00039
00048 struct GiRange {
00049 cxdouble min;
00050 cxdouble max;
00051 };
00052
00053
00065 GiRange *
00066 giraffe_range_new(void)
00067 {
00068
00069 GiRange *self = cx_calloc(1, sizeof *self);
00070 return self;
00071
00072 }
00073
00074
00090 GiRange *
00091 giraffe_range_create(cxdouble min, cxdouble max)
00092 {
00093
00094 const cxchar *fctid = "giraffe_range_create";
00095
00096 GiRange *self = NULL;
00097
00098
00099 if (min > max) {
00100 cpl_error_set(fctid, CPL_ERROR_ILLEGAL_INPUT);
00101 return NULL;
00102 }
00103
00104 self = cx_calloc(1, sizeof *self);
00105
00106 self->min = min;
00107 self->max = max;
00108
00109 return self;
00110
00111 }
00112
00113
00125 void
00126 giraffe_range_delete(GiRange *self)
00127 {
00128
00129 if (self) {
00130 cx_free(self);
00131 }
00132
00133 return;
00134
00135 }
00136
00137
00151 void
00152 giraffe_range_set_min(GiRange *self, cxdouble min)
00153 {
00154
00155 cx_assert(self != NULL);
00156
00157 self->min = min;
00158 return;
00159
00160 }
00161
00162
00174 cxdouble
00175 giraffe_range_get_min(const GiRange *const self)
00176 {
00177
00178 cx_assert(self != NULL);
00179 return self->min;
00180
00181 }
00182
00183
00197 void
00198 giraffe_range_set_max(GiRange *self, cxdouble max)
00199 {
00200
00201 cx_assert(self != NULL);
00202
00203 self->max = max;
00204 return;
00205
00206 }
00207
00208
00220 cxdouble
00221 giraffe_range_get_max(const GiRange *const self)
00222 {
00223
00224 cx_assert(self != NULL);
00225 return self->max;
00226
00227 }