Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccategory: accept all property nodes #633

Merged
merged 4 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/arvgccategory.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ arv_gc_category_get_node_name (ArvDomNode *node)
static gboolean
arv_gc_category_can_append_child (ArvDomNode *parent, ArvDomNode *child)
{
return ARV_IS_GC_PROPERTY_NODE (child) &&
arv_gc_property_node_get_node_type (ARV_GC_PROPERTY_NODE (child)) == ARV_GC_PROPERTY_NODE_TYPE_P_FEATURE;
return ARV_IS_GC_PROPERTY_NODE (child);
}

/* ArvGcCategory implementation */
Expand Down
12 changes: 10 additions & 2 deletions src/arvgcfeaturenode.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ typedef struct {

char *name;
ArvGcNameSpace name_space;
char *comment;

ArvGcPropertyNode *tooltip;
ArvGcPropertyNode *description;
Expand Down Expand Up @@ -174,6 +175,9 @@ arv_gc_feature_node_set_attribute (ArvDomElement *self, const char *name, const
priv->name_space = ARV_GC_NAME_SPACE_STANDARD;
else
priv->name_space = ARV_GC_NAME_SPACE_CUSTOM;
} else if (strcmp (name, "Comment") == 0) {
g_free (priv->comment);
priv->comment = g_strdup (value);
} else
arv_info_dom ("[GcFeature::set_attribute] Unknown attribute '%s'", name);
}
Expand All @@ -185,13 +189,16 @@ arv_gc_feature_node_get_attribute (ArvDomElement *self, const char *name)

if (strcmp (name, "Name") == 0)
return priv->name;
else if (strcmp (name, "NameSpace") == 0)
else if (strcmp (name, "NameSpace") == 0) {
switch (priv->name_space) {
case ARV_GC_NAME_SPACE_STANDARD:
return "Standard";
default:
return "Custom";
}
}
} else if (strcmp (name, "Comment") == 0) {
return priv->comment;
}

arv_info_dom ("[GcFeature::set_attribute] Unknown attribute '%s'", name);

Expand Down Expand Up @@ -547,6 +554,7 @@ arv_gc_feature_node_finalize (GObject *object)
ArvGcFeatureNodePrivate *priv = arv_gc_feature_node_get_instance_private (ARV_GC_FEATURE_NODE(object));

g_clear_pointer (&priv->name, g_free);
g_clear_pointer (&priv->comment, g_free);
g_clear_pointer (&priv->string_buffer, g_free);

G_OBJECT_CLASS (arv_gc_feature_node_parent_class)->finalize (object);
Expand Down
3 changes: 3 additions & 0 deletions tests/data/genicam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
xsi:schemaLocation="http://www.genicam.org/GenApi/Version_1_0 GenApiSchema.xsd">

<Category Name="Root" NameSpace="Standard">
<Description>description</Description>
<ToolTip>tooltip</ToolTip>
<DisplayName>display_name</DisplayName>
<pFeature>RWFloat</pFeature>
<pFeature>RWBoolean</pFeature>
<pFeature>RWInteger</pFeature>
Expand Down
32 changes: 32 additions & 0 deletions tests/genicam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,37 @@ visibility_test (void)
g_object_unref (device);
}

static void
category_test (void)
{
ArvDevice *device;
ArvGc *genicam;
ArvGcNode *node;
GError *error = NULL;
const GSList *features;

device = arv_fake_device_new ("TEST0", &error);
g_assert (ARV_IS_FAKE_DEVICE (device));
g_assert (error == NULL);

genicam = arv_device_get_genicam (device);
g_assert (ARV_IS_GC (genicam));

node = arv_gc_get_node (genicam, "Root");
g_assert (ARV_IS_GC_FEATURE_NODE (node));
g_assert (ARV_IS_GC_CATEGORY (node));

g_assert_cmpstr (arv_gc_feature_node_get_description (ARV_GC_FEATURE_NODE (node)), ==, "description");
g_assert_cmpstr (arv_gc_feature_node_get_tooltip (ARV_GC_FEATURE_NODE (node)), ==, "tooltip");
g_assert_cmpstr (arv_gc_feature_node_get_display_name (ARV_GC_FEATURE_NODE (node)), ==, "display_name");

features = arv_gc_category_get_features (ARV_GC_CATEGORY (node));

g_assert_cmpint (g_slist_length ((GSList *) features), ==, 8);

g_object_unref (device);
}

int
main (int argc, char *argv[])
{
Expand All @@ -1122,6 +1153,7 @@ main (int argc, char *argv[])
g_test_add_func ("/genicam/chunk-data", chunk_data_test);
g_test_add_func ("/genicam/indexed", indexed_test);
g_test_add_func ("/genicam/visibility", visibility_test);
g_test_add_func ("/genicam/category", category_test);

result = g_test_run();

Expand Down