Skip to content

Make message write() take payload as a const reference #600

@patkenneally

Description

@patkenneally

Describe the bug
Message<T>::write currently takes messageType* (non-const) as aq parameter. The function body does not mutate the argument and has no intention/need to mutate it. The non-const signature is a misrepresentation to callers, in particular callers, that want to declare an outgoing payload as const (an often natural choice given the payload is often deemed immutable once computed) cannot, because &payload won't bind to messageType*.

Code like the folloeing doesn't compile:
const AttRefMsgF32Payload attRefOut = this->algorithm->update(callTime, inputRef, attStates); this->attRefOutMsg.write(&attRefOut, this->moduleID, callTime);

We should make the messaging API clear about its read-only treatment of caller data, and not inhibit const-correct payloads in module code.

To reproduce
Steps to reproduce the behavior:
On any system the following does not compile
const AttRefMsgF32Payload attRefOut = this->algorithm->update(callTime, inputRef, attStates); this->attRefOutMsg.write(&attRefOut, this->moduleID, callTime);

Expected behavior
Make it compile by taking a reference.

Screenshots
If applicable, add screenshots/plots to help explain your problem.

Desktop (please complete the following information):

  • OS: All
  • Version All
  • Python version All

Additional context
The existing function call should be deprecated.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions