[aravis] gv_device: add an accessor to the url regex.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] gv_device: add an accessor to the url regex.
- Date: Wed, 18 Jan 2012 20:52:17 +0000 (UTC)
commit 0fde43144c87158ec1a331ac98a7b79054c365cd
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Wed Jan 18 21:51:25 2012 +0100
gv_device: add an accessor to the url regex.
docs/reference/aravis/aravis-sections.txt | 1 +
src/arvgvdevice.c | 18 +++++++++++++-----
src/arvgvdevice.h | 1 +
tests/genicam.c | 22 ++++++++++++++++++++++
4 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index 17e6919..80f5c92 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -437,6 +437,7 @@ ARV_GV_DEVICE_HEARTBEAT_RETRY_TIMEOUT_S
ARV_GV_DEVICE_BUFFER_SIZE
ArvGvDeviceClass
ArvGvDevicePrivate
+arv_gv_device_get_url_regex
</SECTION>
<SECTION>
diff --git a/src/arvgvdevice.c b/src/arvgvdevice.c
index d112db7..140dd38 100644
--- a/src/arvgvdevice.c
+++ b/src/arvgvdevice.c
@@ -35,7 +35,6 @@
#include <stdlib.h>
static GObjectClass *parent_class = NULL;
-static GRegex *arv_gv_device_url_regex = NULL;
/* Shared data (main thread - heartbeat) */
@@ -70,6 +69,18 @@ struct _ArvGvDevicePrivate {
size_t genicam_xml_size;
};
+GRegex *
+arv_gv_device_get_url_regex (void)
+{
+static GRegex *arv_gv_device_url_regex = NULL;
+
+ if (arv_gv_device_url_regex == NULL)
+ arv_gv_device_url_regex = g_regex_new ("^(local:|file:|http:)(.+\\.[^;]+);?([0-9:a-f]*)?;?([0-9:a-f]*)?$",
+ G_REGEX_CASELESS, 0, NULL);
+
+ return arv_gv_device_url_regex;
+}
+
static gboolean
_read_memory (ArvGvDeviceIOData *io_data, guint32 address, guint32 size, void *buffer)
{
@@ -482,7 +493,7 @@ _load_genicam (ArvGvDevice *gv_device, guint32 address, size_t *size)
arv_debug_device ("[GvDevice::load_genicam] xml url = '%s' at 0x%x", filename, address);
- tokens = g_regex_split (arv_gv_device_url_regex, filename, 0);
+ tokens = g_regex_split (arv_gv_device_get_url_regex (), filename, 0);
if (tokens[0] != NULL) {
if (g_strcmp0 (tokens[1], "File:") == 0)
@@ -817,9 +828,6 @@ arv_gv_device_class_init (ArvGvDeviceClass *gv_device_class)
device_class->write_memory = arv_gv_device_write_memory;
device_class->read_register = arv_gv_device_read_register;
device_class->write_register = arv_gv_device_write_register;
-
- arv_gv_device_url_regex = g_regex_new ("^(local:|file:|http:)(.+\\.[^;]+);?([0-9:a-f]*)?;?([0-9:a-f]*)?$",
- G_REGEX_CASELESS, 0, NULL);
}
G_DEFINE_TYPE (ArvGvDevice, arv_gv_device, ARV_TYPE_DEVICE)
diff --git a/src/arvgvdevice.h b/src/arvgvdevice.h
index f67efab..937575f 100644
--- a/src/arvgvdevice.h
+++ b/src/arvgvdevice.h
@@ -64,6 +64,7 @@ GType arv_gv_device_get_type (void);
ArvDevice * arv_gv_device_new (GInetAddress *interface_address, GInetAddress *device_address);
guint64 arv_gv_device_get_timestamp_tick_frequency (ArvGvDevice *gv_device);
+GRegex * arv_gv_device_get_url_regex (void);
G_END_DECLS
diff --git a/tests/genicam.c b/tests/genicam.c
index c4f4618..45f760b 100644
--- a/tests/genicam.c
+++ b/tests/genicam.c
@@ -113,6 +113,27 @@ enumeration_test (void)
g_object_unref (device);
}
+GRegex *arv_gv_device_get_url_regex (void);
+
+static void
+url_test (void)
+{
+ char **tokens;
+ unsigned int i;
+
+ tokens = g_regex_split (arv_gv_device_get_url_regex (), "Local:Basler_Ace_GigE_e7c9b87e_Version_3_3.zip;c0000000;10cca", 0);
+
+ g_assert_cmpint (g_strv_length (tokens), ==, 6);
+
+ g_assert_cmpstr (tokens[0], ==, "");
+ g_assert_cmpstr (tokens[1], ==, "Local:");
+ g_assert_cmpstr (tokens[2], ==, "Basler_Ace_GigE_e7c9b87e_Version_3_3.zip");
+ g_assert_cmpstr (tokens[3], ==, "c0000000");
+ g_assert_cmpstr (tokens[4], ==, "10cca");
+
+ g_strfreev (tokens);
+}
+
int
main (int argc, char *argv[])
{
@@ -129,6 +150,7 @@ main (int argc, char *argv[])
g_test_add_func ("/genicam/boolean", boolean_test);
g_test_add_func ("/genicam/float", float_test);
g_test_add_func ("/genicam/enumeration", enumeration_test);
+ g_test_add_func ("/genicam/url", url_test);
result = g_test_run();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]