[libosinfo PATCH v2 2/6] resources: Add osinfo_resources_{get, set}_inherit()

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

 



Those two private functions will help to keep track whether the
resources should be inherited or not.

https://gitlab.com/libosinfo/osinfo-db/issues/15

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 osinfo/Makefile.am                |  1 +
 osinfo/osinfo_resources.c         | 33 ++++++++++++++++++++++++-
 osinfo/osinfo_resources_private.h | 40 +++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 osinfo/osinfo_resources_private.h

diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 86f6344..394dee0 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -150,6 +150,7 @@ libosinfo_private_header_files =	\
   osinfo_install_script_private.h	\
   osinfo_product_private.h		\
   osinfo_media_private.h		\
+  osinfo_resources_private.h		\
   ignore-value.h			\
   $(NULL)
 
diff --git a/osinfo/osinfo_resources.c b/osinfo/osinfo_resources.c
index 8c116fa..bb39425 100644
--- a/osinfo/osinfo_resources.c
+++ b/osinfo/osinfo_resources.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
+#include "osinfo_resources_private.h"
 
 G_DEFINE_TYPE(OsinfoResources, osinfo_resources, OSINFO_TYPE_ENTITY);
 
@@ -59,7 +60,7 @@ enum {
 
 struct _OsinfoResourcesPrivate
 {
-    gboolean unused;
+    gboolean inherit;
 };
 
 static void
@@ -340,6 +341,20 @@ gint64 osinfo_resources_get_storage(OsinfoResources *resources)
             (OSINFO_ENTITY(resources), OSINFO_RESOURCES_PROP_STORAGE);
 }
 
+/**
+ * osinfo_resources_get_inherit
+ * @resources: an #OsinfoResources instance
+ *
+ * Returns whether its values are inherited
+ *
+ * Mind that this method is *private*!
+ */
+gboolean osinfo_resources_get_inherit(OsinfoResources *resources)
+{
+    g_return_val_if_fail(OSINFO_IS_RESOURCES(resources), FALSE);
+    return resources->priv->inherit;
+}
+
 /**
  * osinfo_resources_set_n_cpus:
  * @resources: an #OsinfoResources instance
@@ -396,6 +411,22 @@ void osinfo_resources_set_storage(OsinfoResources *resources, gint64 storage)
                                   storage);
 }
 
+/**
+ * osinfo_resources_set_inherit
+ * @resources: an #OsinfoResources instance
+ * @inherit: whether its values are inherited
+ *
+ * Sets whether the resources values are inherited
+ *
+ * Mind that this method is *private*!
+ */
+void osinfo_resources_set_inherit(OsinfoResources *resources, gboolean inherit)
+{
+    g_return_if_fail(OSINFO_IS_RESOURCES(resources));
+
+    resources->priv->inherit = inherit;
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_resources_private.h b/osinfo/osinfo_resources_private.h
new file mode 100644
index 0000000..f1df181
--- /dev/null
+++ b/osinfo/osinfo_resources_private.h
@@ -0,0 +1,40 @@
+/*
+ * libosinfo: Required or recommended resources for an (guest) OS
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *   Fabiano Fidêncio <fidencio@xxxxxxxxxx>
+ */
+
+#include <osinfo/osinfo_resources.h>
+
+#ifndef __OSINFO_RESOURCES_PRIVATE_H__
+#define __OSINFO_RESOURCES_PRIVATE_H__
+
+void osinfo_resources_set_inherit(OsinfoResources *resources, gboolean inherit);
+gboolean osinfo_resources_get_inherit(OsinfoResources *resources);
+
+#endif /* __OSINFO_RESOURCES_PRIVATE_H__ */
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
2.19.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux