diff options
author | Thomas Haller <thaller@redhat.com> | 2018-08-11 11:08:17 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-08-28 22:27:55 +0200 |
commit | 38273a88712c8841a4d9619f69e522120e2b04b3 (patch) | |
tree | 722f4ede880df8f69788672ce754db6adf4bf3b1 /src/nm-dbus-manager.h | |
parent | 3a99c343d840b0dca9d64d30b62f7781b3592cb0 (diff) | |
download | NetworkManager-38273a88712c8841a4d9619f69e522120e2b04b3.tar.gz |
settings: use delegation instead of inheritance for NMSettingsConnection and NMConnection
NMConnection is an interface, which is implemented by the types
NMSimpleConnection (libnm-core), NMSettingsConnection (src) and
NMRemoteConnection (libnm).
NMSettingsConnection does a lot of things already:
1) it "is-a" NMDBusObject and exports the API of a connection profile
on D-Bus
2) it interacts with NMSettings and contains functionality
for tracking the profiles.
3) it is the base-class of types like NMSKeyfileConnection and
NMIfcfgConnection. These handle how the profile is persisted
on disk.
4) it implements NMConnection interface, to itself track the
settings of the profile.
3) and 4) would be better implemented via delegation than inheritance.
Address 4) and don't let NMSettingsConnection implemente the NMConnection
interface. Instead, a settings-connection references now a NMSimpleConnection
instance, to which it delegates for keeping the actual profiles.
Advantages:
- by delegating, there is a clearer separation of what
NMSettingsConnection does. For example, in C we often required
casts from NMSettingsConnection to NMConnection. NMConnection
is a very trivial object with very little logic. When we have
a NMConnection instance at hand, it's good to know that it is
*only* that simple instead of also being an entire
NMSettingsConnection instance.
The main purpose of this patch is to simplify the code by separating
the NMConnection from the NMSettingsConnection. We should generally
be aware whether we handle a NMSettingsConnection or a trivial
NMConnection instance. Now, because NMSettingsConnection no longer
"is-a" NMConnection, this distinction is apparent.
- NMConnection is implemented as an interface and we create
NMSimpleConnection instances whenever we need a real instance.
In GLib, interfaces have a performance overhead, that we needlessly
pay all the time. With this change, we no longer require
NMConnection to be an interface. Thus, in the future we could compile
a version of libnm-core for the daemon, where NMConnection is not an
interface but a GObject implementation akin to NMSimpleConnection.
- In the previous implementation, we cannot treat NMConnection immutable
and copy-on-write.
For example, when NMDevice needs a snapshot of the activated
profile as applied-connection, all it can do is clone the entire
NMSettingsConnection as a NMSimpleConnection.
Likewise, when we get a NMConnection instance and want to keep
a reference to it, we cannot do that, because we never know
who also references and modifies the instance.
By separating NMSettingsConnection we could in the future have
NMConnection immutable and copy-on-write, to avoid all unnecessary
clones.
Diffstat (limited to 'src/nm-dbus-manager.h')
-rw-r--r-- | src/nm-dbus-manager.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nm-dbus-manager.h b/src/nm-dbus-manager.h index a07413168d..04c42bb0f6 100644 --- a/src/nm-dbus-manager.h +++ b/src/nm-dbus-manager.h @@ -61,7 +61,7 @@ gboolean nm_dbus_manager_is_stopping (NMDBusManager *self); GDBusConnection *nm_dbus_manager_get_connection (NMDBusManager *self); -NMDBusObject *nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path); +gpointer nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path); void _nm_dbus_manager_obj_export (NMDBusObject *obj); void _nm_dbus_manager_obj_unexport (NMDBusObject *obj); |