[aravis/dom] gc_index_node: new sublcassed property node.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis/dom] gc_index_node: new sublcassed property node.
- Date: Thu, 1 Mar 2012 10:18:28 +0000 (UTC)
commit ae1c9c16d98dd845863b0776599634546afb361e
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Thu Mar 1 11:16:08 2012 +0100
gc_index_node: new sublcassed property node.
src/Makefile.am | 2 +
src/arvgc.c | 3 +
src/arvgcindexnode.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/arvgcindexnode.h | 56 ++++++++++++++++++++
src/arvtypes.h | 1 +
5 files changed, 199 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 66bcefe..00f1077 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,6 +47,7 @@ ARAVIS_SRCS = \
arvgc.c \
arvgcnode.c \
arvgcpropertynode.c \
+ arvgcindexnode.c \
arvgcfeaturenode.c \
arvgcregisterdescriptionnode.c \
arvgccategory.c \
@@ -103,6 +104,7 @@ ARAVIS_HDRS = \
arvgc.h \
arvgcnode.h \
arvgcpropertynode.h \
+ arvgcindexnode.h \
arvgcfeaturenode.h \
arvgcregisterdescriptionnode.h \
arvgccategory.h \
diff --git a/src/arvgc.c b/src/arvgc.c
index b61b3fc..b75c277 100644
--- a/src/arvgc.c
+++ b/src/arvgc.c
@@ -32,6 +32,7 @@
#include <arvgc.h>
#include <arvgcnode.h>
#include <arvgcpropertynode.h>
+#include <arvgcindexnode.h>
#include <arvgcregisterdescriptionnode.h>
#include <arvgccategory.h>
#include <arvgcenumeration.h>
@@ -99,6 +100,8 @@ arv_gc_create_element (ArvDomDocument *document, const char *tag_name)
node = arv_gc_swiss_knife_new_integer ();
else if (strcmp (tag_name, "Port") == 0)
node = arv_gc_port_new ();
+ else if (strcmp (tag_name, "pIndex") == 0)
+ node = arv_gc_index_node_new ();
else if (strcmp (tag_name, "RegisterDescription") == 0)
node = arv_gc_register_description_node_new ();
else if (strcmp (tag_name, "pFeature") == 0)
diff --git a/src/arvgcindexnode.c b/src/arvgcindexnode.c
new file mode 100644
index 0000000..ae88277
--- /dev/null
+++ b/src/arvgcindexnode.c
@@ -0,0 +1,137 @@
+/* Aravis - Digital camera library
+ *
+ * Copyright  2009-2012 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: arvgcindex_node
+ * @short_description: Class for IndexNode elements
+ */
+
+#include <arvgcindexnode.h>
+#include <arvgcpropertynode.h>
+#include <arvgc.h>
+#include <arvdomtext.h>
+#include <arvmisc.h>
+#include <string.h>
+
+static GObjectClass *parent_class = NULL;
+
+/* ArvDomNode implementation */
+
+static const char *
+arv_gc_index_node_get_node_name (ArvDomNode *node)
+{
+ return "pIndex";
+}
+
+static gboolean
+arv_gc_index_node_can_append_child (ArvDomNode *parent, ArvDomNode *child)
+{
+ return ARV_IS_DOM_TEXT (child);
+}
+
+/* ArvDomElement implementation */
+
+static void
+arv_gc_index_node_set_attribute (ArvDomElement *self, const char *name, const char *value)
+{
+ ArvGcIndexNode *index_node = ARV_GC_INDEX_NODE (self);
+
+ if (strcmp (name, "Offset") == 0)
+ arv_force_g_value_to_int64 (&index_node->offset, g_ascii_strtoll (value, NULL, 0));
+ else if (strcmp (name, "pOffset") == 0)
+ arv_force_g_value_to_string (&index_node->offset, value);
+}
+
+static const char *
+arv_gc_index_node_get_attribute (ArvDomElement *self, const char *name)
+{
+ g_assert_not_reached ();
+
+ return NULL;
+}
+
+/* ArvGcIndexNode implementation */
+
+gint64
+arv_gc_index_node_get_index (ArvGcIndexNode *index_node, gint64 default_offset)
+{
+ gint64 offset;
+
+ g_return_val_if_fail (ARV_IS_GC_INDEX_NODE (index_node), 0);
+
+ if (G_VALUE_HOLDS_BOOLEAN (&index_node->offset))
+ offset = default_offset;
+ else {
+ ArvGc *genicam;
+
+ genicam = arv_gc_node_get_genicam (ARV_GC_NODE (index_node));
+ offset = arv_gc_get_int64_from_value (genicam, &index_node->offset);
+ }
+
+ return offset * arv_gc_property_node_get_int64 (ARV_GC_PROPERTY_NODE (index_node));
+}
+
+ArvGcNode *
+arv_gc_index_node_new (void)
+{
+ ArvGcPropertyNode *node;
+
+ node = g_object_new (ARV_TYPE_GC_INDEX_NODE, NULL);
+ node->type = ARV_GC_PROPERTY_NODE_TYPE_P_INDEX;
+
+ return ARV_GC_NODE (node);
+}
+
+static void
+arv_gc_index_node_init (ArvGcIndexNode *index_node)
+{
+ g_value_init (&index_node->offset, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&index_node->offset, FALSE);
+}
+
+static void
+arv_gc_index_node_finalize (GObject *object)
+{
+ ArvGcIndexNode *index_node = ARV_GC_INDEX_NODE (object);
+
+ g_value_unset (&index_node->offset);
+
+ parent_class->finalize (object);
+}
+
+static void
+arv_gc_index_node_class_init (ArvGcIndexNodeClass *this_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (this_class);
+ ArvDomNodeClass *dom_node_class = ARV_DOM_NODE_CLASS (this_class);
+ ArvDomElementClass *dom_element_class = ARV_DOM_ELEMENT_CLASS (this_class);
+
+ parent_class = g_type_class_peek_parent (this_class);
+
+ object_class->finalize = arv_gc_index_node_finalize;
+ dom_node_class->get_node_name = arv_gc_index_node_get_node_name;
+ dom_node_class->can_append_child = arv_gc_index_node_can_append_child;
+ dom_element_class->set_attribute = arv_gc_index_node_set_attribute;
+ dom_element_class->get_attribute = arv_gc_index_node_get_attribute;
+}
+
+G_DEFINE_TYPE (ArvGcIndexNode, arv_gc_index_node, ARV_TYPE_GC_PROPERTY_NODE)
diff --git a/src/arvgcindexnode.h b/src/arvgcindexnode.h
new file mode 100644
index 0000000..8c2a550
--- /dev/null
+++ b/src/arvgcindexnode.h
@@ -0,0 +1,56 @@
+/* Aravis - Digital camera library
+ *
+ * Copyright  2009-2012 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>
+ */
+
+#ifndef ARV_GC_INDEX_NODE_H
+#define ARV_GC_INDEX_NODE_H
+
+#include <arvtypes.h>
+#include <arvgcpropertynode.h>
+
+G_BEGIN_DECLS
+
+#define ARV_TYPE_GC_INDEX_NODE (arv_gc_index_node_get_type ())
+#define ARV_GC_INDEX_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ARV_TYPE_GC_INDEX_NODE, ArvGcIndexNode))
+#define ARV_GC_INDEX_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ARV_TYPE_GC_INDEX_NODE, ArvGcIndexNodeClass))
+#define ARV_IS_GC_INDEX_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ARV_TYPE_GC_INDEX_NODE))
+#define ARV_IS_GC_INDEX_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ARV_TYPE_GC_INDEX_NODE))
+#define ARV_GC_INDEX_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ARV_TYPE_GC_INDEX_NODE, ArvGcIndexNodeClass))
+
+typedef struct _ArvGcIndexNodeClass ArvGcIndexNodeClass;
+
+struct _ArvGcIndexNode {
+ ArvGcPropertyNode base;
+
+ GValue offset;
+};
+
+struct _ArvGcIndexNodeClass {
+ ArvGcPropertyNodeClass parent_class;
+};
+
+GType arv_gc_index_node_get_type (void);
+ArvGcNode * arv_gc_index_node_new (void);
+gint64 arv_gc_index_node_get_index (ArvGcIndexNode *index_node, gint64 default_offset);
+
+G_END_DECLS
+
+#endif
diff --git a/src/arvtypes.h b/src/arvtypes.h
index 94acaff..68ae2b1 100644
--- a/src/arvtypes.h
+++ b/src/arvtypes.h
@@ -45,6 +45,7 @@ typedef struct _ArvGc ArvGc;
typedef struct _ArvGcNode ArvGcNode;
typedef struct _ArvGcFeatureNode ArvGcFeatureNode;
typedef struct _ArvGcPropertyNode ArvGcPropertyNode;
+typedef struct _ArvGcIndexNode ArvGcIndexNode;
typedef struct _ArvGcRegisterDescriptionNode ArvGcRegisterDescriptionNode;
typedef struct _ArvGcCategory ArvGcCategory;
typedef struct _ArvGcBoolean ArvGcBoolean;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]