OpenCyphal-Garage / libcyphal

Portable reference implementation of the Cyphal protocol stack in C++ for embedded systems and Linux.
http://opencyphal.org
MIT License
299 stars 501 forks source link

Reduce duplication around `TransferMetadata` #365

Closed pavel-kirienko closed 3 months ago

pavel-kirienko commented 5 months ago

Here:

https://github.com/OpenCyphal-Garage/libcyphal/blob/5e652de5cb6c9172b833fb8426ba619ce99c4963/include/libcyphal/transport/types.hpp#L58-L79

We discussed that inheritance is not a good choice here, so perhaps we should use composition. After some consideration I realized that the current arrangement will require much manual tinkering in the presentation layer and above.

struct TransferMetadata final
{
    TransferId transfer_id{};
    TimePoint  timestamp;
    Priority   priority{};
};

struct MessageTransferMetadata final
{
    TransferMetadata       base;
    cetl::optional<NodeId> publisher_node_id;
};

struct ServiceTransferMetadata final
{
    TransferMetadata base;
    NodeId           remote_node_id{};
};
serges147 commented 3 months ago

Closing as it has been fixed by pr #374