forked from AravisProject/aravis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharvgcintconverternode.c
160 lines (131 loc) · 4.63 KB
/
arvgcintconverternode.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* Aravis - Digital camera library
*
* Copyright © 2009-2022 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Author: Emmanuel Pacaud <[email protected]>
*/
/**
* SECTION: arvgcintconverternode
* @short_description: IntConverter node class
*/
#include <arvgcconverterprivate.h>
#include <arvgcintconverternode.h>
#include <arvgcfeaturenodeprivate.h>
#include <arvevaluator.h>
#include <arvgcinteger.h>
struct _ArvGcIntConverterNode {
ArvGcConverter converter;
};
struct _ArvGcIntConverterNodeClass {
ArvGcConverterClass parent_class;
};
static const char *
arv_gc_int_converter_node_get_node_name (ArvDomNode *node)
{
return "IntConverter";
}
ArvGcNode *
arv_gc_int_converter_node_new (void)
{
return g_object_new (ARV_TYPE_GC_INT_CONVERTER_NODE, NULL);
}
static void
arv_gc_int_converter_node_init (ArvGcIntConverterNode *node)
{
}
static void
arv_gc_int_converter_node_class_init (ArvGcIntConverterNodeClass *this_class)
{
ArvDomNodeClass *dom_node_class = ARV_DOM_NODE_CLASS (this_class);
dom_node_class->get_node_name = arv_gc_int_converter_node_get_node_name;
}
static gint64
arv_gc_converter_get_integer_value (ArvGcInteger *gc_integer, GError **error)
{
return arv_gc_converter_convert_to_int64 (ARV_GC_CONVERTER (gc_integer), ARV_GC_CONVERTER_NODE_TYPE_VALUE, error);
}
static gint64
arv_gc_converter_get_integer_min (ArvGcInteger *gc_integer, GError **error)
{
GError *local_error = NULL;
gint64 a, b;
/* TODO: we should use the Slope node here, instead of using MIN (min, max) */
a = arv_gc_converter_convert_to_int64 (ARV_GC_CONVERTER (gc_integer), ARV_GC_CONVERTER_NODE_TYPE_MIN, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return G_MININT64;
}
b = arv_gc_converter_convert_to_int64 (ARV_GC_CONVERTER (gc_integer), ARV_GC_CONVERTER_NODE_TYPE_MAX, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return G_MININT64;
}
return MIN (a, b);
}
static gint64
arv_gc_converter_get_integer_max (ArvGcInteger *gc_integer, GError **error)
{
GError *local_error = NULL;
gint64 a, b;
/* TODO: we should use the Slope node here, instead of using MAX (min, max) */
a = arv_gc_converter_convert_to_int64 (ARV_GC_CONVERTER (gc_integer), ARV_GC_CONVERTER_NODE_TYPE_MIN, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return G_MAXINT64;
}
b = arv_gc_converter_convert_to_int64 (ARV_GC_CONVERTER (gc_integer), ARV_GC_CONVERTER_NODE_TYPE_MAX, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return G_MAXINT64;
}
return MAX (a, b);
}
static gint64
_get_inc (ArvGcInteger *self, GError **error)
{
/* Genicam 2.1.1 p. 41 says: The increment of an IntConvertor is always 1. */
return 1;
}
static void
arv_gc_converter_set_integer_value (ArvGcInteger *gc_integer, gint64 value, GError **error)
{
arv_gc_converter_convert_from_int64 (ARV_GC_CONVERTER (gc_integer), value, error);
}
static ArvGcRepresentation
arv_gc_converter_get_integer_representation (ArvGcInteger *gc_integer)
{
return arv_gc_converter_get_representation (ARV_GC_CONVERTER (gc_integer));
}
static const char *
arv_gc_converter_get_integer_unit (ArvGcInteger *gc_integer)
{
return arv_gc_converter_get_unit (ARV_GC_CONVERTER (gc_integer));
}
static void
arv_gc_int_converter_node_integer_interface_init (ArvGcIntegerInterface *interface)
{
interface->get_value = arv_gc_converter_get_integer_value;
interface->get_min = arv_gc_converter_get_integer_min;
interface->get_max = arv_gc_converter_get_integer_max;
interface->get_inc = _get_inc;
interface->set_value = arv_gc_converter_set_integer_value;
interface->get_representation = arv_gc_converter_get_integer_representation;
interface->get_unit = arv_gc_converter_get_integer_unit;
}
G_DEFINE_TYPE_WITH_CODE (ArvGcIntConverterNode, arv_gc_int_converter_node, ARV_TYPE_GC_CONVERTER,
G_IMPLEMENT_INTERFACE (ARV_TYPE_GC_INTEGER, arv_gc_int_converter_node_integer_interface_init))