[virt-tools-list] [libosinfo v2 4/8] InstallConfigParam props should map to entity params

Christophe Fergeau cfergeau at redhat.com
Mon Nov 12 10:22:39 UTC 2012


On Fri, Nov 09, 2012 at 04:14:20PM +0100, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> 
> Without entity params usage, there is no real benefit of deriving from
> Entity class so this was very much intended from start.

Looks like the members of OsInfoInstallConfigParam::priv are no longer used
after this commit?

> ---
>  osinfo/osinfo_install_config_param.c | 48 +++++++++++++++++++-----------------
>  osinfo/osinfo_install_config_param.h |  3 +++
>  2 files changed, 29 insertions(+), 22 deletions(-)
> 
> diff --git a/osinfo/osinfo_install_config_param.c b/osinfo/osinfo_install_config_param.c
> index 40d59b4..c6366c2 100644
> --- a/osinfo/osinfo_install_config_param.c
> +++ b/osinfo/osinfo_install_config_param.c
> @@ -65,17 +65,15 @@ osinfo_install_config_param_set_property(GObject *object,
>      switch (property_id)
>          {
>          case PROP_NAME:
> -            config_param->priv->name = g_value_dup_string(value);
> +            osinfo_entity_set_param(OSINFO_ENTITY(config_param),
> +                                    OSINFO_INSTALL_CONFIG_PARAM_PROP_NAME,
> +                                    g_value_get_string(value));
>              break;
>          case PROP_POLICY:
>              {
> -            const gchar *policy = g_value_get_string(value);
> -            if (g_strcmp0(policy, "required") == 0)
> -                config_param->priv->policy =
> -                    OSINFO_INSTALL_CONFIG_PARAM_POLICY_REQUIRED;
> -            else if (g_strcmp0(policy, "optional") == 0)
> -                config_param->priv->policy =
> -                    OSINFO_INSTALL_CONFIG_PARAM_POLICY_OPTIONAL;
> +            osinfo_entity_set_param(OSINFO_ENTITY(config_param),
> +                                    OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY,
> +                                    g_value_get_string(value));
>              break;
>              }
>          default:
> @@ -97,10 +95,20 @@ osinfo_install_config_param_get_property(GObject *object,
>      switch (property_id)
>          {
>          case PROP_NAME:
> -            g_value_set_string(value, config_param->priv->name);
> +            {
> +            const gchar *name;
> +
> +            name = osinfo_install_config_param_get_name(config_param);
> +            g_value_set_string(value, name);
>              break;
> +            }
>          case PROP_POLICY:
> -            g_value_set_enum(value, config_param->priv->policy);
> +            {
> +            OsinfoInstallConfigParamPolicy policy;
> +
> +            policy = osinfo_install_config_param_get_policy(config_param);
> +            g_value_set_enum(value, policy);
> +            }
>              break;
>          default:
>              /* We don't have any other property... */
> @@ -212,7 +220,8 @@ OsinfoInstallConfigParam *osinfo_install_config_param_new(const gchar *name,
>   */
>  const gchar *osinfo_install_config_param_get_name(const OsinfoInstallConfigParam *config_param)
>  {
> -    return config_param->priv->name;
> +    return osinfo_entity_get_param_value(OSINFO_ENTITY(config_param),
> +                                         OSINFO_INSTALL_CONFIG_PARAM_PROP_NAME);
>  }
>  
>  /**
> @@ -223,7 +232,8 @@ const gchar *osinfo_install_config_param_get_name(const OsinfoInstallConfigParam
>   */
>  OsinfoInstallConfigParamPolicy osinfo_install_config_param_get_policy(const OsinfoInstallConfigParam *config_param)
>  {
> -    return config_param->priv->policy;
> +    return osinfo_entity_get_param_value(OSINFO_ENTITY(config_param),
> +                                         OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY);
>  }
>  
>  /**
> @@ -235,11 +245,8 @@ OsinfoInstallConfigParamPolicy osinfo_install_config_param_get_policy(const Osin
>   */
>  gboolean osinfo_install_config_param_is_required(const OsinfoInstallConfigParam *config_param)
>  {
> -    if (config_param->priv->policy ==
> -            OSINFO_INSTALL_CONFIG_PARAM_POLICY_REQUIRED)
> -        return TRUE;
> -
> -    return FALSE;
> +    return (osinfo_install_config_param_get_policy(config_param) ==
> +            OSINFO_INSTALL_CONFIG_PARAM_POLICY_REQUIRED);
>  }
>  
>  /**
> @@ -251,11 +258,8 @@ gboolean osinfo_install_config_param_is_required(const OsinfoInstallConfigParam
>   */
>  gboolean osinfo_install_config_param_is_optional(const OsinfoInstallConfigParam *config_param)
>  {
> -    if (config_param->priv->policy ==
> -            OSINFO_INSTALL_CONFIG_PARAM_POLICY_OPTIONAL)
> -        return TRUE;
> -
> -    return FALSE;
> +    return (osinfo_install_config_param_get_policy(config_param) ==
> +            OSINFO_INSTALL_CONFIG_PARAM_POLICY_OPTIONAL);
>  }
>  
>  /*
> diff --git a/osinfo/osinfo_install_config_param.h b/osinfo/osinfo_install_config_param.h
> index dbe5e23..d588616 100644
> --- a/osinfo/osinfo_install_config_param.h
> +++ b/osinfo/osinfo_install_config_param.h
> @@ -36,6 +36,9 @@
>  #define OSINFO_IS_INSTALL_CONFIG_PARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_INSTALL_CONFIG_PARAM))
>  #define OSINFO_INSTALL_CONFIG_PARAM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_INSTALL_CONFIG_PARAM, OsinfoInstallConfigParamClass))
>  
> +#define OSINFO_INSTALL_CONFIG_PARAM_PROP_NAME   "name"
> +#define OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY "policy"
> +
>  typedef struct _OsinfoInstallConfigParam        OsinfoInstallConfigParam;
>  typedef struct _OsinfoInstallConfigParamClass   OsinfoInstallConfigParamClass;
>  typedef struct _OsinfoInstallConfigParamPrivate OsinfoInstallConfigParamPrivate;
> -- 
> 1.8.0
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20121112/5213cac0/attachment.sig>


More information about the virt-tools-list mailing list