refactor: invert dependency between Message and Connection #457
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reorganizes the layers of abstraction in the sense how
Message
depends onConnection
and vice versa. Now,Message
has a link to theConnection
. This replaces the shortcut link to the low-levelSdBus
interface that theMessage
kept. The interactions fromMessage
now go throughConnection
which forwards them toSdBus
.Connection
is now a sole owner of the low-levelSdBus
interface. This allows for future changes aroundSdBus
(e.g. a change from virtual functions back to non-virtual functions) without affecting the rest of the library.Proxy
s andObject
s can now send messages directly without having to go throughConnection
. TheConnection
no more depends onMessage
business-logic methods; it serves only as a factory for messages.The flow for creating messages:
Proxy
/Object
->Connection
->SdBus
The flow for sending messages: (
Proxy
/Object
->)Message
->Connection
->SdBus
This also better reflects how dependencies are managed in the underlying sd-bus library.
Additionally,
getSdBusInterface()
methods are removed which was anyway planned, and improves the design by "Tell, don't ask" principle.This refactoring is the necessary enabler for other upcoming improvements (regarding sending long messages, or creds refactoring, for example).