NetworkManager/src/tests
Thomas Haller 38273a8871 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.
2018-08-28 22:27:55 +02:00
..
config build: create "config-extra.h" header instead of passing directory variables via CFLAGS 2018-07-17 17:46:39 +02:00
meson.build all: replace systemd's siphash24 with c-siphash 2018-05-31 15:59:38 +02:00
test-dcb.c all: modify line separator comments to be 80 chars wide 2016-10-03 12:01:15 +02:00
test-general-with-expect.c all: remove CLOCK_BOOTTIME defintions 2018-06-18 17:21:32 +02:00
test-general.c all: don't use gchar/gshort/gint/glong but C types 2018-07-11 12:02:06 +02:00
test-ip4-config.c core: reject invalid domains from ip configurations 2018-05-14 15:22:50 +02:00
test-ip6-config.c core: reject invalid domains from ip configurations 2018-05-14 15:22:50 +02:00
test-secret-agent.py python: make test-secret-agent.py python3 ready 2016-12-14 19:00:42 +01:00
test-systemd.c systemd: merge branch systemd into master 2017-09-21 15:33:32 +02:00
test-utils.c core: add assertions for network_id/stable_type 2017-01-09 14:50:33 +01:00
test-wired-defname.c settings: use delegation instead of inheritance for NMSettingsConnection and NMConnection 2018-08-28 22:27:55 +02:00