summaryrefslogtreecommitdiffstats
path: root/src/cameras
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-04-19 16:45:11 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-04-19 16:45:11 +0200
commit42e3c64fa57039d7673c61f909b5fd40a437bdfd (patch)
treeb9552183c0b1f56aa98395ac760e5d0ec79b2b0e /src/cameras
parente23aff7cfa16d7d3446f59e9100341f060a08e11 (diff)
downloaduca-42e3c64fa57039d7673c61f909b5fd40a437bdfd.tar.gz
uca-42e3c64fa57039d7673c61f909b5fd40a437bdfd.tar.bz2
uca-42e3c64fa57039d7673c61f909b5fd40a437bdfd.tar.xz
uca-42e3c64fa57039d7673c61f909b5fd40a437bdfd.zip
Export base properties and string array
The benefits are two-fold: Camera implementations "know" which base properties exist without looking into the implementation source. Moreover, they can re-use the property strings rather than stating them over and over again. These change should reduce potential c&p errors.
Diffstat (limited to 'src/cameras')
-rw-r--r--src/cameras/uca-mock-camera.c35
-rw-r--r--src/cameras/uca-pco-camera.c36
-rw-r--r--src/cameras/uca-ufo-camera.c30
3 files changed, 28 insertions, 73 deletions
diff --git a/src/cameras/uca-mock-camera.c b/src/cameras/uca-mock-camera.c
index 17a722f..97614a1 100644
--- a/src/cameras/uca-mock-camera.c
+++ b/src/cameras/uca-mock-camera.c
@@ -23,7 +23,11 @@
G_DEFINE_TYPE(UcaMockCamera, uca_mock_camera, UCA_TYPE_CAMERA)
enum {
- PROP_0,
+ PROP_FRAMERATE = N_BASE_PROPERTIES,
+ N_PROPERTIES
+};
+
+static const gint mock_overrideables[] = {
PROP_SENSOR_WIDTH,
PROP_SENSOR_HEIGHT,
PROP_SENSOR_BITDEPTH,
@@ -39,28 +43,7 @@ enum {
PROP_SENSOR_MAX_FRAME_RATE,
PROP_HAS_STREAMING,
PROP_HAS_CAMRAM_RECORDING,
- N_INTERFACE_PROPERTIES,
-
- PROP_FRAMERATE,
- N_PROPERTIES
-};
-
-static const gchar *mock_overrideables[N_PROPERTIES] = {
- "sensor-width",
- "sensor-height",
- "sensor-bitdepth",
- "sensor-horizontal-binning",
- "sensor-horizontal-binnings",
- "sensor-vertical-binning",
- "sensor-vertical-binnings",
- "exposure-time",
- "roi-x",
- "roi-y",
- "roi-width",
- "roi-height",
- "max-frame-rate",
- "has-streaming",
- "has-camram-recording"
+ 0,
};
static GParamSpec *mock_properties[N_PROPERTIES] = { NULL, };
@@ -357,8 +340,8 @@ static void uca_mock_camera_class_init(UcaMockCameraClass *klass)
camera_class->stop_recording = uca_mock_camera_stop_recording;
camera_class->grab = uca_mock_camera_grab;
- for (guint id = PROP_0 + 1; id < N_INTERFACE_PROPERTIES; id++)
- g_object_class_override_property(gobject_class, id, mock_overrideables[id-1]);
+ for (guint i = 0; mock_overrideables[i] != 0; i++)
+ g_object_class_override_property(gobject_class, mock_overrideables[i], uca_camera_props[mock_overrideables[i]]);
mock_properties[PROP_FRAMERATE] =
g_param_spec_float("frame-rate",
@@ -367,7 +350,7 @@ static void uca_mock_camera_class_init(UcaMockCameraClass *klass)
1.0f, 100.0f, 100.0f,
G_PARAM_READWRITE);
- for (guint id = N_INTERFACE_PROPERTIES + 1; id < N_PROPERTIES; id++)
+ for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++)
g_object_class_install_property(gobject_class, id, mock_properties[id]);
g_type_class_add_private(klass, sizeof(UcaMockCameraPrivate));
diff --git a/src/cameras/uca-pco-camera.c b/src/cameras/uca-pco-camera.c
index a2eb259..b808766 100644
--- a/src/cameras/uca-pco-camera.c
+++ b/src/cameras/uca-pco-camera.c
@@ -70,7 +70,12 @@ GQuark uca_pco_camera_error_quark()
}
enum {
- PROP_0,
+ PROP_NAME = N_BASE_PROPERTIES,
+ PROP_COOLING_POINT,
+ N_PROPERTIES
+};
+
+static gint base_overrideables[] = {
PROP_SENSOR_WIDTH,
PROP_SENSOR_HEIGHT,
PROP_SENSOR_BITDEPTH,
@@ -85,28 +90,7 @@ enum {
PROP_ROI_HEIGHT,
PROP_HAS_STREAMING,
PROP_HAS_CAMRAM_RECORDING,
- N_INTERFACE_PROPERTIES,
-
- PROP_NAME,
- PROP_COOLING_POINT,
- N_PROPERTIES
-};
-
-static const gchar *base_overrideables[N_PROPERTIES] = {
- "sensor-width",
- "sensor-height",
- "sensor-bitdepth",
- "sensor-horizontal-binning",
- "sensor-horizontal-binnings",
- "sensor-vertical-binning",
- "sensor-vertical-binnings",
- "max-frame-rate",
- "roi-x",
- "roi-y",
- "roi-width",
- "roi-height",
- "has-streaming",
- "has-camram-recording"
+ 0
};
static GParamSpec *pco_properties[N_PROPERTIES] = { NULL, };
@@ -572,8 +556,8 @@ static void uca_pco_camera_class_init(UcaPcoCameraClass *klass)
camera_class->start_readout = uca_pco_camera_start_readout;
camera_class->grab = uca_pco_camera_grab;
- for (guint id = PROP_0 + 1; id < N_INTERFACE_PROPERTIES; id++)
- g_object_class_override_property(gobject_class, id, base_overrideables[id-1]);
+ for (guint i = 0; base_overrideables[i] != 0; i++)
+ g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]);
pco_properties[PROP_NAME] =
g_param_spec_string("name",
@@ -592,7 +576,7 @@ static void uca_pco_camera_class_init(UcaPcoCameraClass *klass)
"Cooling point of the camera",
0, 10, 5, G_PARAM_READWRITE);
- for (guint id = N_INTERFACE_PROPERTIES + 1; id < N_PROPERTIES; id++)
+ for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++)
g_object_class_install_property(gobject_class, id, pco_properties[id]);
g_type_class_add_private(klass, sizeof(UcaPcoCameraPrivate));
diff --git a/src/cameras/uca-ufo-camera.c b/src/cameras/uca-ufo-camera.c
index f40227b..e7a138d 100644
--- a/src/cameras/uca-ufo-camera.c
+++ b/src/cameras/uca-ufo-camera.c
@@ -54,7 +54,11 @@ GQuark uca_ufo_camera_error_quark()
}
enum {
- PROP_0,
+ PROP_NAME = N_BASE_PROPERTIES,
+ N_PROPERTIES
+};
+
+static gint base_overrideables[] = {
PROP_SENSOR_WIDTH,
PROP_SENSOR_HEIGHT,
PROP_SENSOR_BITDEPTH,
@@ -65,23 +69,7 @@ enum {
PROP_ROI_HEIGHT,
PROP_HAS_STREAMING,
PROP_HAS_CAMRAM_RECORDING,
- N_INTERFACE_PROPERTIES,
-
- PROP_NAME,
- N_PROPERTIES
-};
-
-static const gchar *base_overrideables[N_PROPERTIES] = {
- "sensor-width",
- "sensor-height",
- "sensor-bitdepth",
- "exposure-time",
- "roi-x",
- "roi-y",
- "roi-width",
- "roi-height",
- "has-streaming",
- "has-camram-recording"
+ 0,
};
static GParamSpec *ufo_properties[N_PROPERTIES] = { NULL, };
@@ -308,8 +296,8 @@ static void uca_ufo_camera_class_init(UcaUfoCameraClass *klass)
camera_class->start_readout = uca_ufo_camera_start_readout;
camera_class->grab = uca_ufo_camera_grab;
- for (guint id = PROP_0 + 1; id < N_INTERFACE_PROPERTIES; id++)
- g_object_class_override_property(gobject_class, id, base_overrideables[id-1]);
+ for (guint i = 0; base_overrideables[i] != 0; i++)
+ g_object_class_override_property(gobject_class, base_overrideables[i], uca_camera_props[base_overrideables[i]]);
ufo_properties[PROP_NAME] =
g_param_spec_string("name",
@@ -317,7 +305,7 @@ static void uca_ufo_camera_class_init(UcaUfoCameraClass *klass)
"Name of the camera",
"", G_PARAM_READABLE);
- for (guint id = N_INTERFACE_PROPERTIES + 1; id < N_PROPERTIES; id++)
+ for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++)
g_object_class_install_property(gobject_class, id, ufo_properties[id]);
g_type_class_add_private(klass, sizeof(UcaUfoCameraPrivate));