Question & Answer
Question
Using in/out/inout direction modifiers to control the argument type signature in operations.
Answer
How many times when you have created a type in a model did you end up wanting three or four types (T, T*, const T& ...)?
From the same type you can get four different flavors depending on the way the type is used: As In, Out, InOut arguments
or as a ReturnType.
How does it work?
Each modeled type has an additional four properties under CPP_CG::Type -
- In - the signature of the type when the argument direction is set to In
- Out - the signature of the type when the argument direction is set to Out
- InOut - the signature of the type when the argument direction is set to Inout
- ReturnType -the signature of the type when used as a return type
All the properties are set by default to $type which is resolved as the type name.
You can modify each of the properties to reflect the way the type should be used in different directions (for example,
"const $type&" for In direction in C++).
The generated code is modified according to the change in properties (and you can roundtrip the code without any problems).
Usage example:
Say that you want to use this mechanism for classes in the model (e.g. when selecting a type you want to see all the classes in the model, and you want to use the argument In/Out modifiers to control the way the selected class is used).
- Create a package named classTypesPkg in the model and set its CPP_CG::Type::In/Out ... properties.
- Create a VBA macro that iterates over the model and adds a type to the classTypesPkg for each class in the model.
- When selecting a type for an argument, you can select any of the classes in the model and have it generated with the correct signature by setting the argument direction modifiers.
[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General Information","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]
Historical Number
10247
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21323569