[libvirt] [libvirt-gconfig PATCHv2 13/32] Add gobject boilerplate for GVirConfigOs

Christophe Fergeau cfergeau at redhat.com
Mon Nov 21 18:04:10 UTC 2011


---
 libvirt-gconfig/Makefile.am          |    2 +
 libvirt-gconfig/libvirt-gconfig-os.c |   79 ++++++++++++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-os.h |   67 ++++++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig.h    |    3 +-
 libvirt-gconfig/libvirt-gconfig.sym  |    4 ++
 5 files changed, 154 insertions(+), 1 deletions(-)
 create mode 100644 libvirt-gconfig/libvirt-gconfig-os.c
 create mode 100644 libvirt-gconfig/libvirt-gconfig-os.h

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 13655f9..648ded0 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -19,6 +19,7 @@ GCONFIG_HEADER_FILES = \
 			libvirt-gconfig-network.h \
 			libvirt-gconfig-network-filter.h \
 			libvirt-gconfig-node-device.h \
+			libvirt-gconfig-os.h \
 			libvirt-gconfig-secret.h \
 			libvirt-gconfig-timer.h \
 			libvirt-gconfig-storage-pool.h \
@@ -38,6 +39,7 @@ GCONFIG_SOURCE_FILES = \
 			libvirt-gconfig-network.c \
 			libvirt-gconfig-network-filter.c \
 			libvirt-gconfig-node-device.c \
+			libvirt-gconfig-os.c \
 			libvirt-gconfig-secret.c \
 			libvirt-gconfig-timer.c \
 			libvirt-gconfig-storage-pool.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c
new file mode 100644
index 0000000..c09e32a
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-os.c
@@ -0,0 +1,79 @@
+/*
+ * libvirt-gobject-config_os.c: libvirt glib integration
+ *
+ * Copyright (C) 2011 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: Christophe Fergeau <cfergeau at gmail.com>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <libxml/tree.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_OS_GET_PRIVATE(obj)                         \
+        (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_OS, GVirConfigOsPrivate))
+
+struct _GVirConfigOsPrivate
+{
+    gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigOs, gvir_config_os, GVIR_TYPE_CONFIG_OBJECT);
+
+
+static void gvir_config_os_class_init(GVirConfigOsClass *klass)
+{
+    g_type_class_add_private(klass, sizeof(GVirConfigOsPrivate));
+}
+
+
+static void gvir_config_os_init(GVirConfigOs *os)
+{
+    GVirConfigOsPrivate *priv;
+
+    DEBUG("Init GVirConfigOs=%p", os);
+
+    priv = os->priv = GVIR_CONFIG_OS_GET_PRIVATE(os);
+
+    memset(priv, 0, sizeof(*priv));
+}
+
+
+GVirConfigOs *gvir_config_os_new(void)
+{
+    GVirConfigObject *object;
+
+    object = gvir_config_object_new(GVIR_TYPE_CONFIG_OS, "os", NULL);
+    return GVIR_CONFIG_OS(object);
+}
+
+GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error)
+{
+    GVirConfigObject *object;
+
+    object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_OS, "os",
+                                             NULL, xml, error);
+    return GVIR_CONFIG_OS(object);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-os.h b/libvirt-gconfig/libvirt-gconfig-os.h
new file mode 100644
index 0000000..716f588
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-os.h
@@ -0,0 +1,67 @@
+/*
+ * libvirt-gobject-os.c: libvirt gobject integration
+ *
+ * Copyright (C) 2011 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: Christophe Fergeau <cfergeau at gmail.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_OS_H__
+#define __LIBVIRT_GCONFIG_OS_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_TYPE_CONFIG_OS            (gvir_config_os_get_type ())
+#define GVIR_CONFIG_OS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_TYPE_CONFIG_OS, GVirConfigOs))
+#define GVIR_CONFIG_OS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_TYPE_CONFIG_OS, GVirConfigOsClass))
+#define GVIR_IS_CONFIG_OS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_TYPE_CONFIG_OS))
+#define GVIR_IS_CONFIG_OS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_CONFIG_OS))
+#define GVIR_CONFIG_OS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_CONFIG_OS, GVirConfigOsClass))
+
+typedef struct _GVirConfigOs GVirConfigOs;
+typedef struct _GVirConfigOsPrivate GVirConfigOsPrivate;
+typedef struct _GVirConfigOsClass GVirConfigOsClass;
+
+struct _GVirConfigOs
+{
+    GVirConfigObject parent;
+
+    GVirConfigOsPrivate *priv;
+
+    /* Do not add fields to this struct */
+};
+
+struct _GVirConfigOsClass
+{
+    GVirConfigObjectClass parent_class;
+
+    gpointer padding[20];
+};
+
+
+GType gvir_config_os_get_type(void);
+
+GVirConfigOs *gvir_config_os_new(void);
+GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_OS_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 26ad20e..482c088 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -35,8 +35,9 @@
 #include <libvirt-gconfig/libvirt-gconfig-helpers.h>
 #include <libvirt-gconfig/libvirt-gconfig-interface.h>
 #include <libvirt-gconfig/libvirt-gconfig-network.h>
-#include <libvirt-gconfig/libvirt-gconfig-node-device.h>
 #include <libvirt-gconfig/libvirt-gconfig-network-filter.h>
+#include <libvirt-gconfig/libvirt-gconfig-node-device.h>
+#include <libvirt-gconfig/libvirt-gconfig-os.h>
 #include <libvirt-gconfig/libvirt-gconfig-secret.h>
 #include <libvirt-gconfig/libvirt-gconfig-timer.h>
 #include <libvirt-gconfig/libvirt-gconfig-storage-pool.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 0b60c7c..138b80f 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -50,6 +50,10 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_object_to_xml;
 	gvir_config_object_validate;
 
+	gvir_config_os_get_type;
+	gvir_config_os_new;
+	gvir_config_os_new_from_xml;
+
 	gvir_config_secret_get_type;
 	gvir_config_secret_new;
 	gvir_config_secret_new_from_xml;
-- 
1.7.7.3




More information about the libvir-list mailing list