diff --git a/modulemd/v2/include/modulemd-2.0/modulemd-component-module.h b/modulemd/v2/include/modulemd-2.0/modulemd-component-module.h index 3748685d8..9e86af3dd 100644 --- a/modulemd/v2/include/modulemd-2.0/modulemd-component-module.h +++ b/modulemd/v2/include/modulemd-2.0/modulemd-component-module.h @@ -35,14 +35,15 @@ G_DECLARE_FINAL_TYPE (ModulemdComponentModule, /** * modulemd_component_module_new: - * @name: (not nullable): The name of this module component. + * @key: (not nullable): The key of this module component. Used when looking up + * components from a #ModulemdModuleStream. * * Returns: (transfer full): A newly-allocated #ModulemdComponentModule object. * * Since: 2.0 */ ModulemdComponentModule * -modulemd_component_module_new (const gchar *name); +modulemd_component_module_new (const gchar *key); /** diff --git a/modulemd/v2/include/modulemd-2.0/modulemd-component-rpm.h b/modulemd/v2/include/modulemd-2.0/modulemd-component-rpm.h index bd7eb487a..2257fb362 100644 --- a/modulemd/v2/include/modulemd-2.0/modulemd-component-rpm.h +++ b/modulemd/v2/include/modulemd-2.0/modulemd-component-rpm.h @@ -35,14 +35,15 @@ G_DECLARE_FINAL_TYPE (ModulemdComponentRpm, /** * modulemd_component_rpm_new: - * @name: (not nullable): The name of this module component. + * @key: (not nullable): The key of this module component. Used when looking up + * components from a #ModulemdModuleStream. * * Returns: (transfer full): A newly-allocated #ModulemdComponentRpm object. * * Since: 2.0 */ ModulemdComponentRpm * -modulemd_component_rpm_new (const gchar *name); +modulemd_component_rpm_new (const gchar *key); /** diff --git a/modulemd/v2/include/modulemd-2.0/modulemd-component.h b/modulemd/v2/include/modulemd-2.0/modulemd-component.h index dafe9715e..5e3442f34 100644 --- a/modulemd/v2/include/modulemd-2.0/modulemd-component.h +++ b/modulemd/v2/include/modulemd-2.0/modulemd-component.h @@ -32,7 +32,7 @@ struct _ModulemdComponentClass { GObjectClass parent_class; - ModulemdComponent *(*copy) (ModulemdComponent *self, const gchar *name); + ModulemdComponent *(*copy) (ModulemdComponent *self, const gchar *key); void (*set_name) (ModulemdComponent *self, const gchar *name); const gchar *(*get_name) (ModulemdComponent *self); @@ -44,14 +44,16 @@ struct _ModulemdComponentClass /** * modulemd_component_copy: * @self: This #ModulemdComponent object - * @name: (in) (nullable): An optional new name for the copied component + * @key: (in) (nullable): An optional new key for the copied component which is + * used as the lookup key when this component is attached to a + * #ModulemdModuleStream. * * Returns: (transfer full): A newly-allocated copy of @self * * Since: 2.0 */ ModulemdComponent * -modulemd_component_copy (ModulemdComponent *self, const gchar *name); +modulemd_component_copy (ModulemdComponent *self, const gchar *key); /** diff --git a/modulemd/v2/modulemd-component-module.c b/modulemd/v2/modulemd-component-module.c index 1fc7cfa4e..1962e3cd1 100644 --- a/modulemd/v2/modulemd-component-module.c +++ b/modulemd/v2/modulemd-component-module.c @@ -45,9 +45,9 @@ static GParamSpec *properties[N_PROPS]; ModulemdComponentModule * -modulemd_component_module_new (const gchar *name) +modulemd_component_module_new (const gchar *key) { - return g_object_new (MODULEMD_TYPE_COMPONENT_MODULE, "name", name, NULL); + return g_object_new (MODULEMD_TYPE_COMPONENT_MODULE, "name", key, NULL); } @@ -64,7 +64,7 @@ modulemd_component_module_finalize (GObject *object) static ModulemdComponent * -modulemd_component_module_copy (ModulemdComponent *self, const gchar *name) +modulemd_component_module_copy (ModulemdComponent *self, const gchar *key) { ModulemdComponentModule *module_self = NULL; g_autoptr (ModulemdComponentModule) copy = NULL; @@ -73,7 +73,7 @@ modulemd_component_module_copy (ModulemdComponent *self, const gchar *name) copy = MODULEMD_COMPONENT_MODULE ( MODULEMD_COMPONENT_CLASS (modulemd_component_module_parent_class) - ->copy (self, name)); + ->copy (self, key)); modulemd_component_module_set_ref ( copy, modulemd_component_module_get_ref (module_self)); diff --git a/modulemd/v2/modulemd-component-rpm.c b/modulemd/v2/modulemd-component-rpm.c index 5d75c0673..ffac3407a 100644 --- a/modulemd/v2/modulemd-component-rpm.c +++ b/modulemd/v2/modulemd-component-rpm.c @@ -51,9 +51,9 @@ static GParamSpec *properties[N_PROPS]; ModulemdComponentRpm * -modulemd_component_rpm_new (const gchar *name) +modulemd_component_rpm_new (const gchar *key) { - return g_object_new (MODULEMD_TYPE_COMPONENT_RPM, "name", name, NULL); + return g_object_new (MODULEMD_TYPE_COMPONENT_RPM, "name", key, NULL); } @@ -100,7 +100,7 @@ static const gchar * modulemd_component_rpm_get_name (ModulemdComponent *self); static ModulemdComponent * -modulemd_component_rpm_copy (ModulemdComponent *self, const gchar *name) +modulemd_component_rpm_copy (ModulemdComponent *self, const gchar *key) { ModulemdComponentRpm *rpm_self = NULL; g_autoptr (ModulemdComponentRpm) copy = NULL; @@ -109,7 +109,7 @@ modulemd_component_rpm_copy (ModulemdComponent *self, const gchar *name) copy = MODULEMD_COMPONENT_RPM ( MODULEMD_COMPONENT_CLASS (modulemd_component_rpm_parent_class) - ->copy (self, name)); + ->copy (self, key)); modulemd_component_rpm_set_ref (copy, modulemd_component_rpm_get_ref (rpm_self)); diff --git a/modulemd/v2/modulemd-component.c b/modulemd/v2/modulemd-component.c index 9553b4e09..34cc3065f 100644 --- a/modulemd/v2/modulemd-component.c +++ b/modulemd/v2/modulemd-component.c @@ -60,7 +60,7 @@ modulemd_component_finalize (GObject *object) ModulemdComponent * -modulemd_component_copy (ModulemdComponent *self, const gchar *name) +modulemd_component_copy (ModulemdComponent *self, const gchar *key) { g_return_val_if_fail (self, NULL); @@ -69,20 +69,20 @@ modulemd_component_copy (ModulemdComponent *self, const gchar *name) klass = MODULEMD_COMPONENT_GET_CLASS (self); g_return_val_if_fail (klass->copy, NULL); - return klass->copy (self, name); + return klass->copy (self, key); } static ModulemdComponent * -modulemd_component_copy_component (ModulemdComponent *self, const gchar *name) +modulemd_component_copy_component (ModulemdComponent *self, const gchar *key) { ModulemdComponentPrivate *priv = modulemd_component_get_instance_private (self); g_autoptr (ModulemdComponent) m = NULL; - if (name == NULL) - name = priv->name; + if (key == NULL) + key = priv->name; - m = g_object_new (G_OBJECT_TYPE (self), "name", name, NULL); + m = g_object_new (G_OBJECT_TYPE (self), "name", key, NULL); modulemd_component_set_buildorder (m, modulemd_component_get_buildorder (self)); @@ -214,6 +214,9 @@ modulemd_component_get_property (GObject *object, break; case PROP_NAME: + /* On lookups, return the real name value, not the key. This differs from + * the set function, which always assigns the key. + */ g_value_set_string (value, modulemd_component_get_name (self)); break; @@ -241,6 +244,7 @@ modulemd_component_set_property (GObject *object, break; case PROP_NAME: + /* On object creation, we set the key. */ modulemd_component_set_key (self, g_value_get_string (value)); break; @@ -277,7 +281,9 @@ modulemd_component_class_init (ModulemdComponentClass *klass) properties[PROP_NAME] = g_param_spec_string ( "name", "Name", - "The name of the component.", + "The name of the component. This is the real name of the component and " + "may differ from the key used to associate this component with the " + "ModuleStream.", C_DEFAULT_STRING, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); properties[PROP_RATIONALE] =