nasa / fpp

F Prime Prime: A modeling language for F Prime
https://fprime.jpl.nasa.gov
Apache License 2.0
46 stars 31 forks source link

Remove TlmString, LogString, etc. from generated interface #407

Closed bocchino closed 4 months ago

bocchino commented 4 months ago

String classes like TlmString and LogString appear in the auto-generated C++ component interface. For example, to pass a string argument to an event you have to pass a reference to LogString.

Based on a discussion with @timcanham and @LeStarch, these string classes provide a global truncation parameter. For example, requiring the user to store an event string argument in LogString ensures that the serialized string length is bounded by the minimum of (1) the size declared in the event specifier and (2) the max size of LogString.

As described in #406, we can have the auto-generated code truncate an arbitrary string directly to the min of the two sizes when serializing the string. We do not need the specialized string type to do this truncation. In this approach, the interface for sending commands and events is simpler, because you can pass in any string object to a const Fw::StringBase&. You don't need to first copy your string into the specific string type.

We can use LogString, etc. internally in the generated code, e.g., when declaring auto-generated variables. However, we should eliminate these types from the user interface as much as possible. The change described here should be transparent to user code that uses LogString, etc.