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

[libvirt] [libvirt-glib PATCHv3 19/27] Add GObject boilerplate for GVirConfigDomainInterface



This base class is mainly useful as a generic type when we manipulate
list of interfaces regardless of their actual type.

--
v3: rename to GVirConfigDomainInterface since GVirConfigInterface
    has a different purpose
---
 libvirt-gconfig/Makefile.am                        |    2 +
 libvirt-gconfig/libvirt-gconfig-domain-interface.c |   60 ++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-domain-interface.h |   64 ++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig.h                  |    1 +
 libvirt-gconfig/libvirt-gconfig.sym                |    2 +
 5 files changed, 129 insertions(+), 0 deletions(-)
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface.c
 create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-interface.h

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 4945554..a797db0 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -15,6 +15,7 @@ GCONFIG_HEADER_FILES = \
 			libvirt-gconfig-domain-clock.h \
 			libvirt-gconfig-domain-device.h \
 			libvirt-gconfig-domain-disk.h \
+			libvirt-gconfig-domain-interface.h \
 			libvirt-gconfig-domain-os.h \
 			libvirt-gconfig-domain-snapshot.h \
 			libvirt-gconfig-domain-timer.h \
@@ -36,6 +37,7 @@ GCONFIG_SOURCE_FILES = \
 			libvirt-gconfig-domain-clock.c \
 			libvirt-gconfig-domain-device.c \
 			libvirt-gconfig-domain-disk.c \
+			libvirt-gconfig-domain-interface.c \
 			libvirt-gconfig-domain-os.c \
 			libvirt-gconfig-domain-snapshot.c \
 			libvirt-gconfig-domain-timer.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.c b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
new file mode 100644
index 0000000..ecabfae
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
@@ -0,0 +1,60 @@
+/*
+ * libvirt-gobject-config-domain-interface.c: libvirt glib integration
+ *
+ * Copyright (C) 2008 Daniel P. Berrange
+ * Copyright (C) 2010 Red Hat
+ *
+ * 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.1 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: Daniel P. Berrange <berrange redhat com>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+
+extern gboolean debugFlag;
+
+#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0)
+
+#define GVIR_CONFIG_DOMAIN_INTERFACE_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterfacePrivate))
+
+struct _GVirConfigDomainInterfacePrivate
+{
+    gboolean unused;
+};
+
+G_DEFINE_ABSTRACT_TYPE(GVirConfigDomainInterface, gvir_config_domain_interface, GVIR_TYPE_CONFIG_DOMAIN_DEVICE);
+
+
+static void gvir_config_domain_interface_class_init(GVirConfigDomainInterfaceClass *klass)
+{
+    g_type_class_add_private(klass, sizeof(GVirConfigDomainInterfacePrivate));
+}
+
+
+static void gvir_config_domain_interface_init(GVirConfigDomainInterface *interface)
+{
+    GVirConfigDomainInterfacePrivate *priv;
+
+    DEBUG("Init GVirConfigDomainInterface=%p", interface);
+
+    priv = interface->priv = GVIR_CONFIG_DOMAIN_INTERFACE_GET_PRIVATE(interface);
+
+    memset(priv, 0, sizeof(*priv));
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.h b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
new file mode 100644
index 0000000..cf60936
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
@@ -0,0 +1,64 @@
+/*
+ * libvirt-gconfig-domain-interface.h: libvirt gobject integration
+ *
+ * Copyright (C) 2010 Red Hat
+ *
+ * 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.1 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: Daniel P. Berrange <berrange redhat com>
+ */
+
+#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD)
+#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_TYPE_CONFIG_DOMAIN_INTERFACE            (gvir_config_domain_interface_get_type ())
+#define GVIR_CONFIG_DOMAIN_INTERFACE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterface))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterfaceClass))
+#define GVIR_IS_CONFIG_DOMAIN_INTERFACE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE))
+#define GVIR_IS_CONFIG_DOMAIN_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE))
+#define GVIR_CONFIG_DOMAIN_INTERFACE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterfaceClass))
+
+typedef struct _GVirConfigDomainInterface GVirConfigDomainInterface;
+typedef struct _GVirConfigDomainInterfacePrivate GVirConfigDomainInterfacePrivate;
+typedef struct _GVirConfigDomainInterfaceClass GVirConfigDomainInterfaceClass;
+
+struct _GVirConfigDomainInterface
+{
+    GVirConfigDomainDevice parent;
+
+    GVirConfigDomainInterfacePrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainInterfaceClass
+{
+    GVirConfigDomainDeviceClass parent_class;
+
+    gpointer padding[20];
+};
+
+
+GType gvir_config_domain_interface_get_type(void);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_INTERFACE_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 5d1d8dd..151d09a 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -32,6 +32,7 @@
 #include <libvirt-gconfig/libvirt-gconfig-domain-clock.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-device.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-disk.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-interface.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-os.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
 #include <libvirt-gconfig/libvirt-gconfig-domain-timer.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index eb3a6a8..6244d6d 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -44,6 +44,8 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_domain_disk_set_target_dev;
 	gvir_config_domain_disk_set_type;
 
+	gvir_config_domain_interface_get_type;
+
 	gvir_config_domain_os_get_type;
 	gvir_config_domain_os_boot_device_get_type;
 	gvir_config_domain_os_sm_bios_mode_get_type;
-- 
1.7.7.3


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