-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy patharvgcfloat.c
144 lines (112 loc) · 3.99 KB
/
arvgcfloat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* Aravis - Digital camera library
*
* Copyright © 2009-2010 Emmanuel Pacaud
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Emmanuel Pacaud <emmanuel@gnome.org>
*/
/**
* SECTION: arvgcfloat
* @short_description: Float interface
*/
#include <arvgcfloat.h>
#include <arvmisc.h>
static void
arv_gc_float_default_init (ArvGcFloatInterface *gc_float_iface)
{
}
G_DEFINE_INTERFACE (ArvGcFloat, arv_gc_float, G_TYPE_OBJECT)
double
arv_gc_float_get_value (ArvGcFloat *gc_float, GError **error)
{
g_return_val_if_fail (ARV_IS_GC_FLOAT (gc_float), 0.0);
g_return_val_if_fail (error == NULL || *error == NULL, 0.0);
return ARV_GC_FLOAT_GET_INTERFACE (gc_float)->get_value (gc_float, error);
}
void
arv_gc_float_set_value (ArvGcFloat *gc_float, double value, GError **error)
{
g_return_if_fail (ARV_IS_GC_FLOAT (gc_float));
g_return_if_fail (error == NULL || *error == NULL);
ARV_GC_FLOAT_GET_INTERFACE (gc_float)->set_value (gc_float, value, error);
}
double
arv_gc_float_get_min (ArvGcFloat *gc_float, GError **error)
{
ArvGcFloatInterface *float_interface;
g_return_val_if_fail (ARV_IS_GC_FLOAT (gc_float), 0.0);
g_return_val_if_fail (error == NULL || *error == NULL, 0.0);
float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float);
if (float_interface->get_min != NULL)
return float_interface->get_min (gc_float, error);
else
return -G_MAXDOUBLE;
}
double
arv_gc_float_get_max (ArvGcFloat *gc_float, GError **error)
{
ArvGcFloatInterface *float_interface;
g_return_val_if_fail (ARV_IS_GC_FLOAT (gc_float), 0.0);
g_return_val_if_fail (error == NULL || *error == NULL, 0.0);
float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float);
if (float_interface->get_max != NULL)
return float_interface->get_max (gc_float, error);
else
return G_MAXDOUBLE;
}
double
arv_gc_float_get_inc (ArvGcFloat *gc_float, GError **error)
{
ArvGcFloatInterface *float_interface;
g_return_val_if_fail (ARV_IS_GC_FLOAT (gc_float), 0.0);
g_return_val_if_fail (error == NULL || *error == NULL, 0.0);
float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float);
if (float_interface->get_inc != NULL)
return float_interface->get_inc (gc_float, error);
else
return 1;
}
const char *
arv_gc_float_get_unit (ArvGcFloat *gc_float, GError **error)
{
ArvGcFloatInterface *float_interface;
g_return_val_if_fail (ARV_IS_GC_FLOAT (gc_float), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float);
if (float_interface->get_unit != NULL)
return float_interface->get_unit (gc_float, error);
else
return NULL;
}
void arv_gc_float_impose_min (ArvGcFloat *gc_float, double minimum, GError **error)
{
ArvGcFloatInterface *float_interface;
g_return_if_fail (ARV_IS_GC_FLOAT (gc_float));
g_return_if_fail (error == NULL || *error == NULL);
float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float);
if (float_interface->impose_min != NULL)
float_interface->impose_min (gc_float, minimum, error);
}
void arv_gc_float_impose_max (ArvGcFloat *gc_float, double maximum, GError **error)
{
ArvGcFloatInterface *float_interface;
g_return_if_fail (ARV_IS_GC_FLOAT (gc_float));
g_return_if_fail (error == NULL || *error == NULL);
float_interface = ARV_GC_FLOAT_GET_INTERFACE (gc_float);
if (float_interface->impose_max != NULL)
float_interface->impose_max (gc_float, maximum, error);
}