[aravis/dom] gc_command: port to the new DOM API.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis/dom] gc_command: port to the new DOM API.
- Date: Fri, 2 Mar 2012 09:54:20 +0000 (UTC)
commit 58687c37d2defa4668365fbb5aa73c8ff82a2537
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Fri Mar 2 10:53:54 2012 +0100
gc_command: port to the new DOM API.
src/arvgc.c | 8 +++++-
src/arvgccategory.c | 13 +++++++--
src/arvgccommand.c | 66 +++++++++++++++++++++++++---------------------
src/arvgccommand.h | 5 ++-
src/arvgcpropertynode.c | 17 ++++++++++++
src/arvgcpropertynode.h | 6 +++-
6 files changed, 78 insertions(+), 37 deletions(-)
---
diff --git a/src/arvgc.c b/src/arvgc.c
index 7ec6fdc..44a4639 100644
--- a/src/arvgc.c
+++ b/src/arvgc.c
@@ -183,6 +183,11 @@ arv_gc_create_element (ArvDomDocument *document, const char *tag_name)
else if (strcmp (tag_name, "pInvalidator") == 0)
node = arv_gc_invalidator_node_new ();
+ else if (strcmp (tag_name, "CommandValue") == 0)
+ node = arv_gc_property_node_new_command_value ();
+ else if (strcmp (tag_name, "pCommandValue") == 0)
+ node = arv_gc_property_node_new_p_command_value ();
+
else if (strcmp (tag_name, "Group") == 0)
node = arv_gc_group_node_new ();
else
@@ -329,7 +334,8 @@ arv_gc_register_feature_node (ArvGc *genicam, ArvGcFeatureNode *node)
g_hash_table_remove (genicam->nodes, (char *) name);
g_hash_table_insert (genicam->nodes, (char *) name, node);
- arv_log_genicam ("[Gc::register_feature_node] Register node '%s'", name);
+ arv_log_genicam ("[Gc::register_feature_node] Register node '%s' [%s]", name,
+ arv_dom_node_get_node_name (ARV_DOM_NODE (node)));
}
ArvGc *
diff --git a/src/arvgccategory.c b/src/arvgccategory.c
index b539149..a48e28b 100644
--- a/src/arvgccategory.c
+++ b/src/arvgccategory.c
@@ -73,6 +73,7 @@ const GSList *
arv_gc_category_get_features (ArvGcCategory *category)
{
ArvDomNode *iter;
+ ArvGcNode *node;
g_return_val_if_fail (ARV_IS_GC_CATEGORY (category), NULL);
@@ -80,9 +81,15 @@ arv_gc_category_get_features (ArvGcCategory *category)
for (iter = arv_dom_node_get_first_child (ARV_DOM_NODE (category));
iter != NULL;
- iter = arv_dom_node_get_next_sibling (iter))
- category->features = g_slist_append (category->features,
- g_strdup (arv_gc_property_node_get_string (ARV_GC_PROPERTY_NODE (iter))));
+ iter = arv_dom_node_get_next_sibling (iter)) {
+ node = arv_gc_property_node_get_linked_node (ARV_GC_PROPERTY_NODE (iter));
+ if (ARV_IS_GC_FEATURE_NODE (node)) {
+ char *name;
+
+ name = g_strdup (arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (node)));
+ category->features = g_slist_append (category->features, name);
+ }
+ }
return category->features;
}
diff --git a/src/arvgccommand.c b/src/arvgccommand.c
index 4ea0358..b6390e1 100644
--- a/src/arvgccommand.c
+++ b/src/arvgccommand.c
@@ -44,26 +44,37 @@ arv_gc_command_get_node_name (ArvDomNode *node)
return "Command";
}
-/* ArvGcFeatureNode implementation */
+static void
+arv_gc_command_post_new_child (ArvDomNode *self, ArvDomNode *child)
+{
+ ArvGcCommand *node = ARV_GC_COMMAND (self);
+
+ if (ARV_IS_GC_PROPERTY_NODE (child)) {
+ ArvGcPropertyNode *property_node = ARV_GC_PROPERTY_NODE (child);
+
+ switch (arv_gc_property_node_get_node_type (property_node)) {
+ case ARV_GC_PROPERTY_NODE_TYPE_VALUE:
+ case ARV_GC_PROPERTY_NODE_TYPE_P_VALUE:
+ node->value = property_node;
+ break;
+ case ARV_GC_PROPERTY_NODE_TYPE_COMMAND_VALUE:
+ case ARV_GC_PROPERTY_NODE_TYPE_P_COMMAND_VALUE:
+ node->value = property_node;
+ break;
+ default:
+ ARV_DOM_NODE_CLASS (parent_class)->post_new_child (self, child);
+ break;
+ }
+ }
+}
-#if 0
static void
-arv_gc_command_add_element (ArvGcFeatureNode *node, const char *name, const char *content, const char **attributes)
+arv_gc_command_pre_remove_child (ArvDomNode *self, ArvDomNode *child)
{
- ArvGcCommand *gc_command = ARV_GC_COMMAND (node);
-
- if (strcmp (name, "Value") == 0) {
- arv_force_g_value_to_int64 (&gc_command->value, g_ascii_strtoull (content, NULL, 0));
- } else if (strcmp (name, "pValue") == 0) {
- arv_force_g_value_to_string (&gc_command->value, content);
- } else if (strcmp (name, "CommandValue") == 0) {
- arv_force_g_value_to_int64 (&gc_command->command_value, g_ascii_strtoull (content, NULL, 0));
- } else if (strcmp (name, "pCommandValue") == 0) {
- arv_force_g_value_to_string (&gc_command->command_value, content);
- } else
- ARV_GC_FEATURE_NODE_CLASS (parent_class)->add_element (node, name, content, attributes);
+ g_assert_not_reached ();
}
-#endif
+
+/* ArvGcFeatureNode implementation */
/* ArvGcCommand implementation */
@@ -77,8 +88,13 @@ arv_gc_command_execute (ArvGcCommand *gc_command)
genicam = arv_gc_node_get_genicam (ARV_GC_NODE (gc_command));
g_return_if_fail (ARV_IS_GC (genicam));
- command_value = arv_gc_get_int64_from_value (genicam, &gc_command->command_value);
- arv_gc_set_int64_to_value (genicam, &gc_command->value, command_value);
+ if (gc_command->command_value != NULL)
+ command_value = arv_gc_property_node_get_int64 (gc_command->command_value);
+ else
+ command_value = 0;
+
+ if (gc_command->value != NULL)
+ arv_gc_property_node_set_int64 (gc_command->value, command_value);
arv_log_genicam ("[GcCommand::execute] %s (0x%x)",
arv_gc_feature_node_get_name (ARV_GC_FEATURE_NODE (gc_command)),
@@ -98,21 +114,11 @@ arv_gc_command_new (void)
static void
arv_gc_command_init (ArvGcCommand *gc_command)
{
- /* Set default to read only 32 bits little endian integer command */
- g_value_init (&gc_command->value, G_TYPE_INT64);
- g_value_init (&gc_command->command_value, G_TYPE_INT64);
- g_value_set_int64 (&gc_command->value, 0);
- g_value_set_int64 (&gc_command->command_value, 0);
}
static void
arv_gc_command_finalize (GObject *object)
{
- ArvGcCommand *gc_command = ARV_GC_COMMAND (object);
-
- g_value_unset (&gc_command->value);
- g_value_unset (&gc_command->command_value);
-
parent_class->finalize (object);
}
@@ -121,13 +127,13 @@ arv_gc_command_class_init (ArvGcCommandClass *this_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (this_class);
ArvDomNodeClass *dom_node_class = ARV_DOM_NODE_CLASS (this_class);
-/* ArvGcFeatureNodeClass *gc_feature_node_class = ARV_GC_FEATURE_NODE_CLASS (this_class);*/
parent_class = g_type_class_peek_parent (this_class);
object_class->finalize = arv_gc_command_finalize;
dom_node_class->get_node_name = arv_gc_command_get_node_name;
-/* gc_feature_node_class->add_element = arv_gc_command_add_element;*/
+ dom_node_class->post_new_child = arv_gc_command_post_new_child;
+ dom_node_class->pre_remove_child = arv_gc_command_pre_remove_child;
}
G_DEFINE_TYPE (ArvGcCommand, arv_gc_command, ARV_TYPE_GC_FEATURE_NODE)
diff --git a/src/arvgccommand.h b/src/arvgccommand.h
index b84202b..7fcd3fc 100644
--- a/src/arvgccommand.h
+++ b/src/arvgccommand.h
@@ -25,6 +25,7 @@
#include <arvtypes.h>
#include <arvgcfeaturenode.h>
+#include <arvgcpropertynode.h>
G_BEGIN_DECLS
@@ -40,8 +41,8 @@ typedef struct _ArvGcCommandClass ArvGcCommandClass;
struct _ArvGcCommand {
ArvGcFeatureNode node;
- GValue command_value;
- GValue value;
+ ArvGcPropertyNode *command_value;
+ ArvGcPropertyNode *value;
};
struct _ArvGcCommandClass {
diff --git a/src/arvgcpropertynode.c b/src/arvgcpropertynode.c
index 68c26f8..2be5423 100644
--- a/src/arvgcpropertynode.c
+++ b/src/arvgcpropertynode.c
@@ -96,6 +96,8 @@ arv_gc_property_node_get_node_name (ArvDomNode *node)
return "MSB";
case ARV_GC_PROPERTY_NODE_TYPE_BIT:
return "Bit";
+ case ARV_GC_PROPERTY_NODE_TYPE_COMMAND_VALUE:
+ return "CommandValue";
case ARV_GC_PROPERTY_NODE_TYPE_P_FEATURE:
return "pFeature";
@@ -119,6 +121,9 @@ arv_gc_property_node_get_node_name (ArvDomNode *node)
return "pPort";
case ARV_GC_PROPERTY_NODE_TYPE_P_VARIABLE:
return "pVariable";
+ case ARV_GC_PROPERTY_NODE_TYPE_P_COMMAND_VALUE:
+ return "pCommandValue";
+
default:
return "Unknown";
}
@@ -497,6 +502,18 @@ arv_gc_property_node_new_bit (void)
return arv_gc_property_node_new (ARV_GC_PROPERTY_NODE_TYPE_BIT);
}
+ArvGcNode *
+arv_gc_property_node_new_command_value (void)
+{
+ return arv_gc_property_node_new (ARV_GC_PROPERTY_NODE_TYPE_COMMAND_VALUE);
+}
+
+ArvGcNode *
+arv_gc_property_node_new_p_command_value (void)
+{
+ return arv_gc_property_node_new (ARV_GC_PROPERTY_NODE_TYPE_P_COMMAND_VALUE);
+}
+
static void
arv_gc_property_node_init (ArvGcPropertyNode *gc_property_node)
{
diff --git a/src/arvgcpropertynode.h b/src/arvgcpropertynode.h
index c87b43e..8aa6c01 100644
--- a/src/arvgcpropertynode.h
+++ b/src/arvgcpropertynode.h
@@ -55,6 +55,7 @@ typedef enum {
ARV_GC_PROPERTY_NODE_TYPE_LSB,
ARV_GC_PROPERTY_NODE_TYPE_MSB,
ARV_GC_PROPERTY_NODE_TYPE_BIT,
+ ARV_GC_PROPERTY_NODE_TYPE_COMMAND_VALUE,
ARV_GC_PROPERTY_NODE_TYPE_P_UNKNONW = 1000,
ARV_GC_PROPERTY_NODE_TYPE_P_FEATURE,
@@ -69,7 +70,8 @@ typedef enum {
ARV_GC_PROPERTY_NODE_TYPE_P_LENGTH,
ARV_GC_PROPERTY_NODE_TYPE_P_PORT,
ARV_GC_PROPERTY_NODE_TYPE_P_VARIABLE,
- ARV_GC_PROPERTY_NODE_TYPE_P_INVALIDATOR
+ ARV_GC_PROPERTY_NODE_TYPE_P_INVALIDATOR,
+ ARV_GC_PROPERTY_NODE_TYPE_P_COMMAND_VALUE
} ArvGcPropertyNodeType;
#define ARV_TYPE_GC_PROPERTY_NODE (arv_gc_property_node_get_type ())
@@ -129,6 +131,8 @@ ArvGcNode * arv_gc_property_node_new_sign (void);
ArvGcNode * arv_gc_property_node_new_lsb (void);
ArvGcNode * arv_gc_property_node_new_msb (void);
ArvGcNode * arv_gc_property_node_new_bit (void);
+ArvGcNode * arv_gc_property_node_new_command_value (void);
+ArvGcNode * arv_gc_property_node_new_p_command_value (void);
const char * arv_gc_property_node_get_string (ArvGcPropertyNode *node);
void arv_gc_property_node_set_string (ArvGcPropertyNode *node, const char *string);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]