Parameter mapping for C++ (C++ code)
ACS generates a Parameter as part of both the declaration and implementation of an Operation. In each case the code is derived from the properties of the Parameter (Mechanism and Data Type) and the tagged values set for Tag Definitions that are applied by the «C++ Parameter» stereotype.
Properties
• If the Data Type property is set, ACS generates the value as the parameter's data type, unless there is a value set for the C++ Function Pointer Return tag definition, in which case that value is used for the parameter's data type.
If no data type is specified, ACS generates int by default. If you want ACS to generate a different default in the absence of a data type for an Attribute, Parameter or Type Definition, change the default value that is specified in the
Cppgen.ini file.
Tell me more...Reverser Notes: When reverse engineering a parameter's data type:
◦ If the data type is modeled in the Model or is going to be reverse engineered to the Model, the Parameter's Data Type references the appropriate item.
◦ If the data type is not modeled in the Model and is not going to be reverse engineered to the Model, the Parameter's Data Type is set to the name of the data type (as text).
◦ If the data type is a function pointer, the Parameter's Data Type is not set and instead the C++ Function Pointer Return and C++ Function Pointer Parameter tag definitions are used to record the data type.
• If the
Default Value is set, ACS uses the value in the declaration.
Example code • If the
Description property has a value, ACS generates the description as an inline comment after the parameter declaration.
Example code • If the
Mechanism property is set to 'Out' or 'In and Out', the parameter is generated as a pointer. If the Mechanism is set to 'In', the parameter is generated as a const. If a value is set for the C++ Indirection tag definition, the Mechanism property is ignored.
Example code • The Mechanism property is generated as follows:
◦ If the Mechanism is set to 'In and Out', the parameter is generated as a pointer.
◦ If the Mechanism is set to 'In', the parameter is generated as a const, unless the «C++ Parameter» stereotype is applied to the Parameter.
If you want all 'In' Parameters that do not have the «C++ Parameter» stereotype applied to be generated without the const keyword: create a Tag Definition named C++ In Parameter As Const in the model.
◦ If the Mechanism is set to 'Out', the parameter is generated as a pointer, unless the «C++ Parameter» stereotype is applied to the Parameter.
If you want all 'Out' Parameters that do not have the «C++ Parameter» stereotype applied to be generated as references: create a Tag Definition named C++ Out Parameter As Reference in the Model, and set its Default Value to TRUE.
| • If a Parameter's Data Type is a Class, Data Type, Interface or Signal and the Mechanism is 'Out' or 'In and Out', a forward declaration for the type is generated in the header file, and a #include for the type's header file is generated in the implementation file. • If a Parameter's Data Type is a Class and the Mechanism is 'in', a #include for the type's header file is generated in the header file. • If a value is set for the C++ Indirection tag definition, the Mechanism property is ignored. |
Reverser Notes: When reverse engineering parameters, if the parameter has any indirection the Reverser sets the Mechanism to 'In and Out', else the Mechanism is set to 'In'.
• The
Name property is generated as the name of the parameter in the code.
Example code | ACS may modify the parameter name that is added to the code to make it valid for C++. You can specify the exact parameter name to add to the code through the CODE_GENERATION_NAME property of a Parameter. Tell me more... |
Tag Definitions:
The following tag definitions are not included in the C++ Profile, but you can create them in a model if you want the resultant generation of Parameters.
• C++ In Parameter As Const tag definition - if present in a model, Parameters that have their Mechanism set to 'In' and do not have the «C++ Parameter» stereotype applied are not generated as const.
• C++ Out Parameter As Reference tag definition - if present in a model with a Default Value of TRUE, Parameters that have their Mechanism set to 'Out' and do not have the «C++ Parameter» stereotype applied are generated as references.
The following tag definitions are applied to a Parameter by the «C++ Parameter» stereotype:
• If the tagged value of the
C++ Anonymous Item tag definition is set to TRUE, it means that the parameter is used as an anonymous type and is generated with no name.
Example code Reverser Notes: When reverse engineering a parameter that is used as an anonymous type, the Reverser creates a Parameter in Modeler and sets its C++ Anonymous Item tag definition to TRUE. The name of the Parameter is as follows:
unnamed<integer to make unique>
• If the tagged value of the
C++ Actual Template Parameterstag definition has been set, the value is used to generate the text between the angle brackets when the parameter's type is a template class.
Example code • If the tagged value of the
C++ CV Qualifier tag definition is set to const, volatile or const volatile, the selected keyword is generated before the data type.
Example code • If the tagged value of the
C++ Array Spec tag definition has been set, the set value is generated after the parameter name. Note that the value must include any brackets.
Example code • If the tagged values of the C++ Function Pointer Parameters and C++ Function Pointer Return tag definitions have been set, the Parameter declaration is generated as follows:
<C++ Function Pointer Return>(<C++ Indirection><derived C++ Name>)(<C++ Function Pointer Parameters>);
Reverser Notes: When reverse engineering parameters that are of type function pointer, the Reverser uses the tagged values of the C++ Function Pointer Parameters and C++ Function Pointer Return tag definitions to capture the return type and parameters of the function pointer.
• If a tagged value for the
C++ Indirection tag definition has been set, the set value is used as the indirection, that is, the value is generated after the data type and before the parameter name.
Example code • If the tagged value of the
C++ Storage Class tag definition is set to auto, register, extern or mutable, the selected storage class keyword is generated. Note that for a Parameter you should use only the auto or register values.
Example code