[aravis/chunk] chunk: start of chunk parser class implementation



commit eb309587e88c6cdd84d8471426cb828d74d2a9ff
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Tue Jul 15 20:31:40 2014 +0200

    chunk: start of chunk parser class implementation

 src/Makefile.am      |    2 +
 src/arvchunkparser.c |  156 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/arvchunkparser.h |   60 +++++++++++++++++++
 src/arvtypes.h       |    1 +
 4 files changed, 219 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3e00384..ac7eb0f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -68,6 +68,7 @@ ARAVIS_SRCS =                                 \
        arvdevice.c                             \
        arvstream.c                             \
        arvbuffer.c                             \
+       arvchunkparser.c                        \
        arvgvinterface.c                        \
        arvgvdevice.c                           \
        arvgvstream.c                           \
@@ -130,6 +131,7 @@ ARAVIS_HDRS =                                       \
        arvdevice.h                             \
        arvstream.h                             \
        arvbuffer.h                             \
+       arvchunkparser.h                        \
        arvgvinterface.h                        \
        arvgvdevice.h                           \
        arvgvstream.h                           \
diff --git a/src/arvchunkparser.c b/src/arvchunkparser.c
new file mode 100644
index 0000000..64994f4
--- /dev/null
+++ b/src/arvchunkparser.c
@@ -0,0 +1,156 @@
+/* Aravis - Digital camera library
+ *
+ * Copyright © 2009-2014 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+/**
+ * SECTION: arvchunkparser
+ * @short_description: Parser for extraction of chunk data from buffers
+ *
+ * #ArvChunkParser provides a class for the instantiation of chunk parsers used
+ * for the extraction of chunk data stored in the stream payload.
+ */
+
+#include <arvchunkparser.h>
+
+enum {
+       ARV_CHUNK_PARSER_PROPERTY_0,
+       ARV_CHUNK_PARSER_PROPERTY_GENICAM,
+       ARV_CHUNK_PARSER_PROPERTY_LAST
+} ArvStreamProperties;
+
+static GObjectClass *parent_class = NULL;
+
+struct _ArvChunkParserPrivate {
+       ArvGc *genicam;
+};
+
+const char *
+arv_chunk_parser_get_string_feature_value (ArvChunkParser *parser, ArvBuffer *buffer, const char *feature)
+{
+       return NULL;
+}
+
+gint64
+arv_chunk_parser_get_integer_feature_value (ArvChunkParser *parser, ArvBuffer *buffer, const char *feature)
+{
+       return 0;
+}
+
+double
+arv_chunk_parser_get_float_feature_value (ArvChunkParser *parser, ArvBuffer *buffer, const char *feature)
+{
+       return 0.0;
+}
+
+/**
+ * arv_chunk_parser_new:
+ * @genicam: a #ArvGc
+ *
+ * Creates a new chunk_parser.
+ *
+ * Returns: a new #ArvChunkParser object
+ *
+ * Since: 0.3.3
+ */
+
+ArvChunkParser *
+arv_chunk_parser_new (ArvGc *genicam)
+{
+       ArvChunkParser *chunk_parser;
+
+       g_return_val_if_fail (ARV_IS_GC (genicam), NULL);
+
+       chunk_parser = g_object_new (ARV_TYPE_CHUNK_PARSER, "genicam", genicam, NULL);
+
+       return chunk_parser;
+}
+
+static void
+_set_property (GObject * object, guint prop_id,
+              const GValue * value, GParamSpec * pspec)
+{
+       ArvChunkParser *parser = ARV_CHUNK_PARSER (object);
+
+       switch (prop_id) {
+               case ARV_CHUNK_PARSER_PROPERTY_GENICAM:
+                       g_clear_object (&parser->priv->genicam);
+                       parser->priv->genicam = g_object_ref (g_value_get_object (value));
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                       break;
+       }
+}
+
+static void
+_get_property (GObject * object, guint prop_id,
+                        GValue * value, GParamSpec * pspec)
+{
+       ArvChunkParser *parser = ARV_CHUNK_PARSER (object);
+
+       switch (prop_id) {
+               case ARV_CHUNK_PARSER_PROPERTY_GENICAM:
+                       g_value_set_object (value, parser->priv->genicam);
+                       break;
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                       break;
+       }
+}
+
+static void
+arv_chunk_parser_init (ArvChunkParser *chunk_parser)
+{
+       chunk_parser->priv = G_TYPE_INSTANCE_GET_PRIVATE (chunk_parser, ARV_TYPE_CHUNK_PARSER, 
ArvChunkParserPrivate);
+}
+
+static void
+_finalize (GObject *object)
+{
+       ArvChunkParser *chunk_parser = ARV_CHUNK_PARSER (object);
+
+       g_clear_object (&chunk_parser->priv->genicam);
+
+       parent_class->finalize (object);
+}
+
+static void
+arv_chunk_parser_class_init (ArvChunkParserClass *node_class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (node_class);
+
+       g_type_class_add_private (node_class, sizeof (ArvChunkParserPrivate));
+
+       parent_class = g_type_class_peek_parent (node_class);
+
+       object_class->finalize = _finalize;
+       object_class->set_property = _set_property;
+       object_class->get_property = _get_property;
+
+       g_object_class_install_property (
+               object_class, ARV_CHUNK_PARSER_PROPERTY_GENICAM,
+               g_param_spec_object ("genicam", "genicam",
+                                    "Genicam instance", ARV_TYPE_GC,
+                                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
+               );
+}
+
+G_DEFINE_TYPE (ArvChunkParser, arv_chunk_parser, G_TYPE_OBJECT)
diff --git a/src/arvchunkparser.h b/src/arvchunkparser.h
new file mode 100644
index 0000000..161b1c6
--- /dev/null
+++ b/src/arvchunkparser.h
@@ -0,0 +1,60 @@
+/* Aravis - Digital camera library
+ *
+ * Copyright © 2009-2014 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef ARV_CHUNK_PARSER_H
+#define ARV_CHUNK_PARSER_H
+
+#include <arvtypes.h>
+#include <arvgc.h>
+
+G_BEGIN_DECLS
+
+#define ARV_TYPE_CHUNK_PARSER             (arv_chunk_parser_get_type ())
+#define ARV_CHUNK_PARSER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ARV_TYPE_CHUNK_PARSER, 
ArvChunkParser))
+#define ARV_CHUNK_PARSER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ARV_TYPE_CHUNK_PARSER, 
ArvChunkParserClass))
+#define ARV_IS_CHUNK_PARSER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ARV_TYPE_CHUNK_PARSER))
+#define ARV_IS_CHUNK_PARSER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ARV_TYPE_CHUNK_PARSER))
+#define ARV_CHUNK_PARSER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), ARV_TYPE_CHUNK_PARSER, 
ArvChunkParserClass))
+
+typedef struct _ArvChunkParserPrivate ArvChunkParserPrivate;
+typedef struct _ArvChunkParserClass ArvChunkParserClass;
+
+struct _ArvChunkParser {
+       GObject object;
+
+       ArvChunkParserPrivate *priv;
+};
+
+struct _ArvChunkParserClass {
+       GObjectClass parent_class;
+};
+
+GType arv_chunk_parser_get_type (void);
+
+ArvChunkParser *       arv_chunk_parser_new                            (ArvGc *genicam);
+const char *           arv_chunk_parser_get_string_feature_value       (ArvChunkParser *parser, ArvBuffer 
*buffer, const char *feature);
+gint64                 arv_chunk_parser_get_integer_feature_value      (ArvChunkParser *parser, ArvBuffer 
*buffer, const char *feature); 
+double                 arv_chunk_parser_get_float_feature_value        (ArvChunkParser *parser, ArvBuffer 
*buffer, const char *feature);
+
+G_END_DECLS
+
+#endif
diff --git a/src/arvtypes.h b/src/arvtypes.h
index dbcd9f9..1b2721b 100644
--- a/src/arvtypes.h
+++ b/src/arvtypes.h
@@ -72,6 +72,7 @@ typedef struct _ArvInterface          ArvInterface;
 typedef struct _ArvDevice              ArvDevice;
 typedef struct _ArvStream              ArvStream;
 typedef struct _ArvBuffer              ArvBuffer;
+typedef struct _ArvChunkParser         ArvChunkParser;
 
 typedef struct _ArvGvInterface                 ArvGvInterface;
 typedef struct _ArvGvDevice            ArvGvDevice;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]