[aravis] fake: add FakeInterface boilerplate.



commit 6b0a21f4a9219ef58e81cad962f2a3ea25d21d18
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Tue May 4 09:37:25 2010 +0200

    fake: add FakeInterface boilerplate.

 src/Makefile.am        |    2 +
 src/arvfakeinterface.c |   99 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/arvfakeinterface.h |   60 +++++++++++++++++++++++++++++
 src/arvtypes.h         |    1 +
 4 files changed, 162 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 29966e5..4954220 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -58,6 +58,7 @@ libaravis_la_SOURCES =				\
 	arvgvinterface.c			\
 	arvgvdevice.c				\
 	arvgvstream.c				\
+	arvfakeinterface.c			\
 	arvfakedevice.c				\
 	arvfakestream.c
 
@@ -96,6 +97,7 @@ ARAVIS_HDRS = 					\
 	arvgvinterface.h			\
 	arvgvdevice.h				\
 	arvgvstream.h				\
+	arvfakeinterface.h			\
 	arvfakedevice.h				\
 	arvfakestream.h
 
diff --git a/src/arvfakeinterface.c b/src/arvfakeinterface.c
new file mode 100644
index 0000000..319b6ba
--- /dev/null
+++ b/src/arvfakeinterface.c
@@ -0,0 +1,99 @@
+/* Aravis - Digital camera library
+ *
+ * Copyright © 2009-2010 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., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <arvfakeinterface.h>
+#include <arvfakedevice.h>
+#include <arvdebug.h>
+
+static GObjectClass *parent_class = NULL;
+
+struct _ArvFakeInterfacePrivate {
+	GHashTable *devices;
+};
+
+static void
+arv_fake_interface_update_device_list (ArvInterface *interface)
+{
+}
+
+static ArvDevice *
+arv_fake_interface_new_device (ArvInterface *interface, const char *name)
+{
+	return NULL;
+}
+
+ArvInterface *
+arv_fake_interface_get_instance (void)
+{
+	static ArvInterface *fake_interface = NULL;
+	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+
+	g_static_mutex_lock (&mutex);
+
+	if (fake_interface == NULL)
+		fake_interface = g_object_new (ARV_TYPE_FAKE_INTERFACE, NULL);
+	else
+		g_object_ref (fake_interface);
+
+	g_static_mutex_unlock (&mutex);
+
+	return ARV_INTERFACE (fake_interface);
+}
+
+static void
+arv_fake_interface_init (ArvFakeInterface *fake_interface)
+{
+	fake_interface->priv = G_TYPE_INSTANCE_GET_PRIVATE (fake_interface, ARV_TYPE_FAKE_INTERFACE, ArvFakeInterfacePrivate);
+
+	fake_interface->priv->devices = NULL;
+}
+
+static void
+arv_fake_interface_finalize (GObject *object)
+{
+	ArvFakeInterface *fake_interface = ARV_FAKE_INTERFACE (object);
+
+	if (fake_interface->priv->devices != NULL) {
+		g_hash_table_unref (fake_interface->priv->devices);
+		fake_interface->priv->devices = NULL;
+	}
+
+	parent_class->finalize (object);
+}
+
+static void
+arv_fake_interface_class_init (ArvFakeInterfaceClass *fake_interface_class)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (fake_interface_class);
+	ArvInterfaceClass *interface_class = ARV_INTERFACE_CLASS (fake_interface_class);
+
+	g_type_class_add_private (fake_interface_class, sizeof (ArvFakeInterfacePrivate));
+
+	parent_class = g_type_class_peek_parent (fake_interface_class);
+
+	object_class->finalize = arv_fake_interface_finalize;
+
+	interface_class->update_device_list = arv_fake_interface_update_device_list;
+	interface_class->new_device = arv_fake_interface_new_device;
+}
+
+G_DEFINE_TYPE (ArvFakeInterface, arv_fake_interface, ARV_TYPE_INTERFACE)
diff --git a/src/arvfakeinterface.h b/src/arvfakeinterface.h
new file mode 100644
index 0000000..623d184
--- /dev/null
+++ b/src/arvfakeinterface.h
@@ -0,0 +1,60 @@
+/* Aravis - Digital camera library
+ *
+ * Copyright © 2009-2010 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., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef ARV_FAKE_INTERFACE_H
+#define ARV_FAKE_INTERFACE_H
+
+#include <arvtypes.h>
+#include <arvinterface.h>
+
+G_BEGIN_DECLS
+
+#define ARV_FAKE_INTERFACE_DISCOVERY_TIMEOUT_MS	1000
+#define ARV_FAKE_INTERFACE_SOCKET_BUFFER_SIZE	1024
+
+#define ARV_TYPE_FAKE_INTERFACE             (arv_fake_interface_get_type ())
+#define ARV_FAKE_INTERFACE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ARV_TYPE_FAKE_INTERFACE, ArvFakeInterface))
+#define ARV_FAKE_INTERFACE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ARV_TYPE_FAKE_INTERFACE, ArvFakeInterfaceClass))
+#define ARV_IS_FAKE_INTERFACE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ARV_TYPE_FAKE_INTERFACE))
+#define ARV_IS_FAKE_INTERFACE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ARV_TYPE_FAKE_INTERFACE))
+#define ARV_FAKE_INTERFACE_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), ARV_TYPE_FAKE_INTERFACE, ArvFakeInterfaceClass))
+
+typedef struct _ArvFakeInterfacePrivate ArvFakeInterfacePrivate;
+typedef struct _ArvFakeInterfaceClass ArvFakeInterfaceClass;
+
+struct _ArvFakeInterface {
+	ArvInterface	interface;
+
+	ArvFakeInterfacePrivate *priv;
+};
+
+struct _ArvFakeInterfaceClass {
+	ArvInterfaceClass parent_class;
+};
+
+GType arv_fake_interface_get_type (void);
+
+ArvInterface * 		arv_fake_interface_get_instance 		(void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/arvtypes.h b/src/arvtypes.h
index 3dab35d..d66632a 100644
--- a/src/arvtypes.h
+++ b/src/arvtypes.h
@@ -59,6 +59,7 @@ typedef struct _ArvGvInterface 		ArvGvInterface;
 typedef struct _ArvGvDevice 		ArvGvDevice;
 typedef struct _ArvGvStream 		ArvGvStream;
 
+typedef struct _ArvFakeInterface	ArvFakeInterface;
 typedef struct _ArvFakeDevice		ArvFakeDevice;
 typedef struct _ArvFakeStream		ArvFakeStream;
 



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