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.
Describe the bug
Message<T>::writecurrently takesmessageType*(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 asconst(an often natural choice given the payload is often deemed immutable once computed) cannot, because&payloadwon't bind tomessageType*.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):
Additional context
The existing function call should be deprecated.