![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: Rhapsody tip: Using types in/out/inout direction modifiers to con trol the argument t Topic Summary: Created On: 27-Jul-2004 17:53 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
How many times when you wanted to create a type in a model, you ended wanting three or four type (T, T*, const T& ...)?
Well.. Rhapsody 4.0 has the answer for you! and this is code generation for argument direction modifiers. From the same type you can get four different flavors depending on the way the type is used: As an In,Out,Inout arguments or as a return type. How does it work? Each modeled type has an additional four properties under 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 that 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 in the model a package named classTypesPkg and set its CG::Type::In/Out ... properties Create a VBA macro that iterate over the model and add 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. Attached is an example with such usage. Amos |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.