Ejemplo n.º 1
0
ArvDomNode*
arv_dom_node_replace_child (ArvDomNode* self, ArvDomNode* new_child, ArvDomNode* old_child)
{
	ArvDomNode *next_sibling;
	ArvDomNode *node;

	if (new_child == NULL)
		return arv_dom_node_remove_child (self, old_child);

	if (!ARV_IS_DOM_NODE (new_child)) {
		g_critical ("%s: new_child is not a ArvDomNode", G_STRFUNC);
		if (ARV_IS_DOM_NODE (old_child))
			g_object_unref (old_child);
		return NULL;
	}

	if (new_child->parent_node != NULL)
		arv_dom_node_remove_child (self, new_child);

	if (old_child == NULL) {
		arv_debug_dom ("[ArvDomNode::replace_child] old_child == NULL)");
		g_object_unref (new_child);
		return NULL;
	}

	if (!ARV_IS_DOM_NODE (old_child)) {
		g_critical ("%s: old_child is not a ArvDomNode", G_STRFUNC);
		g_object_unref (new_child);
		return NULL;
	}

	if (!ARV_IS_DOM_NODE (self)) {
		g_critical ("%s: self is not a ArvDomNode", G_STRFUNC);
		g_object_unref (new_child);
		g_object_unref (old_child);
		return NULL;
	}

	if (old_child->parent_node != self) {
		g_object_unref (new_child);
		g_object_unref (old_child);
		return NULL;
	}

	next_sibling = old_child->next_sibling;

	node = arv_dom_node_remove_child (self, old_child);
	if (node != old_child) {
		g_object_unref (new_child);
		g_object_unref (old_child);
		return NULL;
	}

	if (next_sibling == NULL)
		arv_dom_node_append_child (self, new_child);
	else
		arv_dom_node_insert_before (self, new_child, next_sibling);

	return old_child;
}
Ejemplo n.º 2
0
static const char *
arv_gc_feature_node_get_attribute (ArvDomElement *self, const char *name)
{
	ArvGcFeatureNode *node = ARV_GC_FEATURE_NODE (self);

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

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

	return NULL;
}
Ejemplo n.º 3
0
static void
arv_gc_feature_node_set_attribute (ArvDomElement *self, const char *name, const char *value)
{
	ArvGcFeatureNode *node = ARV_GC_FEATURE_NODE (self);

	if (strcmp (name, "Name") == 0) {
		ArvGc *genicam;

		g_free (node->priv->name);
		node->priv->name = g_strdup (value);

		genicam = arv_gc_node_get_genicam (ARV_GC_NODE (self));
		/* Kludge around ugly Genicam specification (Really, pre-parsing for EnumEntry Name substitution ?) */
		if (strcmp (arv_dom_node_get_node_name (ARV_DOM_NODE (node)), "EnumEntry") != 0)
			arv_gc_register_feature_node (genicam, node);
	} else if (strcmp (name, "NameSpace") == 0) {
		if (g_strcmp0 (value, "Standard") == 0)
			node->priv->name_space = ARV_GC_NAME_SPACE_STANDARD;
		else
			node->priv->name_space = ARV_GC_NAME_SPACE_CUSTOM;
	} else
		arv_debug_dom ("[GcFeature::set_attribute] Unknown attribute '%s'", name);
}
Ejemplo n.º 4
0
ArvDomNode*
arv_dom_node_insert_before (ArvDomNode* self, ArvDomNode* new_child, ArvDomNode* ref_child)
{
	ArvDomNodeClass *node_class;

	if (ref_child == NULL)
		arv_dom_node_append_child (self, new_child);

	g_return_val_if_fail (ARV_IS_DOM_NODE (new_child), NULL);

	if (new_child->parent_node != NULL)
		arv_dom_node_remove_child (self, new_child);

	if (!ARV_IS_DOM_NODE (self)) {
		g_critical ("%s: self is not a ArvDomNode", G_STRFUNC);
		g_object_unref (new_child);
		return NULL;
	}

	if (!ARV_IS_DOM_NODE (ref_child)) {
		g_critical ("%s: ref_child is not a ArvDomNode", G_STRFUNC);
		g_object_unref (new_child);
		return NULL;
	}

	if (ref_child->parent_node != self) {
		arv_debug_dom ("[ArvDomNode::insert_before] Ref child '%s' doesn't belong to '%s'",
			   arv_dom_node_get_node_name (ref_child),
			   arv_dom_node_get_node_name (self));
		g_object_unref (new_child);
		return NULL;
	}

	if (!ARV_DOM_NODE_GET_CLASS (self)->can_append_child (self, new_child)) {
		arv_log_dom ("[ArvDomNode::insert_before] Can't append '%s' to '%s'",
			   arv_dom_node_get_node_name (new_child),
			   arv_dom_node_get_node_name (self));
		g_object_unref (new_child);
		return NULL;
	}

	new_child->parent_node = self;
	new_child->next_sibling = ref_child;
	new_child->previous_sibling = ref_child->previous_sibling;

	if (ref_child->previous_sibling == NULL)
		self->first_child = new_child;
	else
		ref_child->previous_sibling->next_sibling = new_child;

	ref_child->previous_sibling = new_child;

	node_class = ARV_DOM_NODE_GET_CLASS (self);

	if (node_class->post_new_child)
		node_class->post_new_child (self, new_child);

	arv_dom_node_changed (self);

	return new_child;
}
Ejemplo n.º 5
0
static ArvDomElement *
arv_gc_create_element (ArvDomDocument *document, const char *tag_name)
{
	ArvGcNode *node = NULL;

	if (strcmp (tag_name, "Category") == 0)
		node = arv_gc_category_new ();
	else if (strcmp (tag_name, "Command") == 0)
		node = arv_gc_command_new ();
	else if (strcmp (tag_name, "Converter") == 0)
		node = arv_gc_converter_new ();
	else if (strcmp (tag_name, "IntConverter") == 0)
		node = arv_gc_converter_new_integer ();
	else if (strcmp (tag_name, "IntReg") == 0)
		node = arv_gc_register_node_new_integer ();
	else if (strcmp (tag_name, "MaskedIntReg") == 0)
		node = arv_gc_register_node_new_masked_integer ();
	else if (strcmp (tag_name, "FloatReg") == 0)
		node = arv_gc_register_node_new_float ();
	else if (strcmp (tag_name, "StringReg") == 0)
		node = arv_gc_register_node_new_string ();
	else if (strcmp (tag_name, "StructReg") == 0)
		node = arv_gc_register_node_new_struct_register ();
	else if (strcmp (tag_name, "StructEntry") == 0)
		node = arv_gc_struct_entry_node_new ();
	else if (strcmp (tag_name, "Integer") == 0)
		node = arv_gc_integer_node_new ();
	else if (strcmp (tag_name, "Float") == 0)
		node = arv_gc_float_node_new ();
	else if (strcmp (tag_name, "Boolean") == 0)
		node = arv_gc_boolean_new ();
	else if (strcmp (tag_name, "Enumeration") == 0)
		node = arv_gc_enumeration_new ();
	else if (strcmp (tag_name, "EnumEntry") == 0)
		node = arv_gc_enum_entry_new ();
	else if (strcmp (tag_name, "SwissKnife") == 0)
		node = arv_gc_swiss_knife_new ();
	else if (strcmp (tag_name, "IntSwissKnife") == 0)
		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)
		node = arv_gc_property_node_new_p_feature ();
	else if (strcmp (tag_name, "Value") == 0)
		node = arv_gc_property_node_new_value ();
	else if (strcmp (tag_name, "pValue") == 0)
		node = arv_gc_property_node_new_p_value ();
	else if (strcmp (tag_name, "Address") == 0)
		node = arv_gc_property_node_new_address ();
	else if (strcmp (tag_name, "pAddress") == 0)
		node = arv_gc_property_node_new_p_address ();
	else if (strcmp (tag_name, "Description") == 0)
		node = arv_gc_property_node_new_description ();
	else if (strcmp (tag_name, "ToolTip") == 0)
		node = arv_gc_property_node_new_tooltip ();
	else if (strcmp (tag_name, "DisplayName") == 0)
		node = arv_gc_property_node_new_display_name ();
	else if (strcmp (tag_name, "Min") == 0)
		node = arv_gc_property_node_new_minimum ();
	else if (strcmp (tag_name, "pMin") == 0)
		node = arv_gc_property_node_new_p_minimum ();
	else if (strcmp (tag_name, "Max") == 0)
		node = arv_gc_property_node_new_maximum ();
	else if (strcmp (tag_name, "pMax") == 0)
		node = arv_gc_property_node_new_p_maximum ();
	else if (strcmp (tag_name, "Inc") == 0)
		node = arv_gc_property_node_new_increment ();
	else if (strcmp (tag_name, "pInc") == 0)
		node = arv_gc_property_node_new_p_increment ();
	else if (strcmp (tag_name, "Unit") == 0)
		node = arv_gc_property_node_new_unit ();
	else if (strcmp (tag_name, "OnValue") == 0)
		node = arv_gc_property_node_new_on_value ();
	else if (strcmp (tag_name, "OffValue") == 0)
		node = arv_gc_property_node_new_off_value ();
	else if (strcmp (tag_name, "pIsImplemented") == 0)
		node = arv_gc_property_node_new_p_is_implemented ();
	else if (strcmp (tag_name, "pIsAvailable") == 0)
		node = arv_gc_property_node_new_p_is_available ();
	else if (strcmp (tag_name, "pIsLocked") == 0)
		node = arv_gc_property_node_new_p_is_locked ();
	else if (strcmp (tag_name, "Length") == 0)
		node = arv_gc_property_node_new_length ();
	else if (strcmp (tag_name, "pLength") == 0)
		node = arv_gc_property_node_new_p_length ();
	else if (strcmp (tag_name, "pPort") == 0)
		node = arv_gc_property_node_new_p_port ();
	else if (strcmp (tag_name, "pVariable") == 0)
		node = arv_gc_variable_node_new ();
	else if (strcmp (tag_name, "Formula") == 0)
		node = arv_gc_property_node_new_formula ();
	else if (strcmp (tag_name, "FormulaTo") == 0)
		node = arv_gc_property_node_new_formula_to ();
	else if (strcmp (tag_name, "FormulaFrom") == 0)
		node = arv_gc_property_node_new_formula_from ();
	else if (strcmp (tag_name, "Expression") == 0)
		node = arv_gc_property_node_new_expression ();
	else if (strcmp (tag_name, "Constant") == 0)
		node = arv_gc_property_node_new_constant ();

	else if (strcmp (tag_name, "AccessMode") == 0)
		node = arv_gc_property_node_new_access_mode ();
	else if (strcmp (tag_name, "Cachable") == 0)
		node = arv_gc_property_node_new_cachable ();
	else if (strcmp (tag_name, "PollingTime") == 0)
		node = arv_gc_property_node_new_polling_time ();
	else if (strcmp (tag_name, "Endianess") == 0)
		node = arv_gc_property_node_new_endianess ();
	else if (strcmp (tag_name, "Sign") == 0)
		node = arv_gc_property_node_new_sign ();
	else if (strcmp (tag_name, "LSB") == 0)
		node = arv_gc_property_node_new_lsb ();
	else if (strcmp (tag_name, "MSB") == 0)
		node = arv_gc_property_node_new_msb ();
	else if (strcmp (tag_name, "Bit") == 0)
		node = arv_gc_property_node_new_bit ();
	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
		arv_debug_dom ("[Genicam::create_element] Unknow tag (%s)", tag_name);

	return ARV_DOM_ELEMENT (node);
}