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

Chunk feature access #912

Draft
wants to merge 2 commits into
base: aravis-0-8
Choose a base branch
from
Draft
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
58 changes: 58 additions & 0 deletions src/arvchunkparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,64 @@ arv_chunk_parser_get_float_value (ArvChunkParser *parser, ArvBuffer *buffer, con
return value;
}

static ArvGcNode *
arv_chunk_parser_get_feature (ArvChunkParser *parser, const char *feature)
{
g_return_val_if_fail (ARV_IS_CHUNK_PARSER(parser), NULL);
g_return_val_if_fail (parser->priv->genicam, NULL);

return arv_gc_get_node (parser->priv->genicam, feature);
}

static void *
_get_feature (ArvChunkParser *parser, GType node_type, const char *feature, GError **error)
{
void *node;

g_return_val_if_fail (ARV_IS_CHUNK_PARSER (parser), NULL);
g_return_val_if_fail (feature != NULL, NULL);

node = arv_chunk_parser_get_feature (parser, feature);

if (node == NULL) {
g_set_error (error, ARV_CHUNK_PARSER_ERROR, ARV_CHUNK_PARSER_ERROR_FEATURE_NOT_FOUND,
"[%s] Not found", feature);
return NULL;
}

if (!(G_TYPE_CHECK_INSTANCE_TYPE ((node), node_type))) {
g_set_error (error, ARV_CHUNK_PARSER_ERROR, ARV_CHUNK_PARSER_ERROR_INVALID_FEATURE_TYPE,
"[%s:%s] Not a %s", feature, G_OBJECT_TYPE_NAME (node), g_type_name (node_type));
return NULL;
}

return node;
}

void
arv_chunk_parser_set_string_feature_value (ArvChunkParser *parser,
const char *feature, const char *value,
GError **error)
{
ArvGcNode *node;

node = _get_feature (parser, ARV_TYPE_GC_STRING, feature, error);
if (node != NULL)
arv_gc_string_set_value (ARV_GC_STRING (node), value, error);
}

void
arv_chunk_parser_set_integer_feature_value (ArvChunkParser *parser,
const char *feature, gint64 value,
GError **error)
{
ArvGcNode *node;

node = _get_feature (parser, ARV_TYPE_GC_INTEGER, feature, error);
if (node != NULL)
arv_gc_integer_set_value (ARV_GC_INTEGER (node), value, error);
}

/**
* arv_chunk_parser_new:
* @xml: XML genicam data
Expand Down
10 changes: 9 additions & 1 deletion src/arvchunkparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ ARV_API GQuark arv_chunk_parser_error_quark (void);
typedef enum {
ARV_CHUNK_PARSER_ERROR_INVALID_FEATURE_TYPE,
ARV_CHUNK_PARSER_ERROR_BUFFER_NOT_FOUND,
ARV_CHUNK_PARSER_ERROR_CHUNK_NOT_FOUND
ARV_CHUNK_PARSER_ERROR_CHUNK_NOT_FOUND,
ARV_CHUNK_PARSER_ERROR_FEATURE_NOT_FOUND
} ArvChunkParserError;

#define ARV_TYPE_CHUNK_PARSER (arv_chunk_parser_get_type ())
Expand All @@ -63,6 +64,13 @@ ARV_API gint64 arv_chunk_parser_get_integer_value (ArvChunkParser *parser, Arv
ARV_API double arv_chunk_parser_get_float_value (ArvChunkParser *parser, ArvBuffer *buffer,
const char *chunk, GError **error);

ARV_API void arv_chunk_parser_set_string_feature_value (ArvChunkParser *parser,
const char *feature, const char *value,
GError **error);
ARV_API void arv_chunk_parser_set_integer_feature_value (ArvChunkParser *parser,
const char *feature, gint64 value,
GError **error);

G_END_DECLS

#endif
Loading