Operation mapping for C++ (C++ code)
ACS generates an Operation as a function, either globally, within a namespace or within a class definition:
For constructors, an attribute initializer list is generated if required.
The function declaration and implementation is derived from the properties of the Operation and the tagged values set for Tag Definitions that are applied by the «C++ Operation» and «C++ Function Template» stereotypes.
Child items:
Properties
• If the
Abstract property is set to True (Abstract check box selected on Property Pages), the Operation is generated as a pure virtual C++ method.
Example code If the Operation is a constructor or destructor, ACS ignores the Abstract property.
• If the Visibility property of an Operation is set to Public or Package:
For an Operation owned by a Class, Data Type or Interface, the function is declared in the header file generated for the owning item.
For an Operation owned by the Model or a Package, the function is declared in the header file generated for the owning Model or Package.
• If the Visibility property of an Operation is set to Protected or Private:
For an Operation owned by a Class or Data Type, the function is declared as Protected or Private in the header file generated for the owning item.
For an Operation owned by an Interface, the function is declared as Public in the header file generated for the owning Interface.
For an Operation owned by the Model or a Package, the function is declared in the implementation file generated for the owning Model or Package and marked as static.
If the Operation is a constructor or destructor, ACS ignores the Binding property.
• If the Body property has a value, ACS may generate the value as the body of the associated function.
When generating an Operation that has a blank Body and a Return Type specified, ACS generates the following default body in the code:
<return type> Operation1()
{
<return type> Temp; return Temp;
}
If you add an Event to an Operation Body as a model object reference, ACS can generate the Event as a notification call or as the Event's operational handler.
Tell me more...Reverser Notes: When reverse engineering, the Reverser updates the Operation Body property in Modeler as follows:
◦ If the Reverse Engineer Code Bodies check box (Reverse Engineering Options 1 page) is cleared, the Reverser does not update the Operation Body property in the Model.
◦ If the Reverse Engineer Code Bodies check box (Reverse Engineering Options 1 page) is selected, the Reverser updates the Operation Body property with the associated function body code. Note that blank function body code will result in the associated Operation's Body property being made blank.
◦ When updating Operation Body properties, the Reverser attempts to preserve model object references.
• If the
Description property has a value, ACS generates the description as a comment on the line before the function.
Example code • If the
Immutable property is set True (Immutable check box selected on Property Pages), the const keyword is used.
Example code | ACS may modify the function name that is added to the code to make it valid for C++. You can specify the exact function name to add to the code through the CODE_GENERATION_NAME property of an Operation.
Tell me more... |
• If the Return Type property is set, ACS generates the value as the function's return type, unless there is a value set for the C++ Function Pointer Return tag definition, in which case that value is used for the function's return type.
If no data type is specified, ACS generates void by default, except for constructors and destructors in which case no return type is generated. If you want ACS to generate a different default in the absence of a data type for an Operation, change the default value that is specified in the
Cppgen.ini file.
Tell me more...Reverser Notes: When reverse engineering an function's return type:
◦ If the return type is modeled in the Model or is going to be reverse engineered to the Model, the Operation's Return Type references the appropriate item.
◦ If the return type is not modeled in the Model and is not going to be reverse engineered to the Model, the Operation's Data Type is set to the name of the return type as text.
◦ If the return type is a function pointer, the Operation's Return Type is not set and instead the C++ Function Pointer Return and C++ Function Pointer Parameter tag definitions are used to record the return type.
• The Timing properties (Synchronization and Duration) are ignored.
Tag Definitions:
When the «C++ Macro» stereotype is applied to an Operation, ACS generates the Operation as a function macro: #define <operation name> (<comma separated list of parameters>) <operation body code>
The following tag definitions are applied to an Operation by the «C++ Operation» or «C++ Function Template» stereotypes:
• If the tagged value of the
C++ Actual Template Parameters tag definition has been set, the value is used to generate the text between the angle brackets when the return 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++ Explicit tag definition is set to TRUE, the explicit keyword is used. Ensure that you set the value to TRUE only for single parameter constructions.
Example code Note that the explicit keyword should be used only with constructors.
• If the tagged value of the
C++ Formal Template Parameters tag definition (applied by «C++ Function Template» has been set, the set value is used as the formal template parameter list of a template function.
Example code • If the tagged value of the
C++ Function Pointer Return tag definitions has been set, the Attribute declaration is generated as follows using any parameters specified by the tagged value of the
C++ Function Pointer Parameters:
Example code Operation Declaration:
<C++ Function Pointer Return>(<C++ Indirection><derived C++ Name>(<Parameters>))(<C++ Function Pointer Parameters>);
Operation Implementation:
<C++ Function Pointer Return>(<C++ Indirection><derived C++ Name>(<Parameters>))(<C++ Function Pointer Parameters>);
Reverser Notes: When reverse engineering functions that are of type function pointer, the C++ Function Pointer Return and C++ Function Pointer Parameters tag definitions are used to record the function pointer and parameters.
• If the tagged value of the
C++ Indirection tag definition has been set, the set value is used as an indirection, that is, the value is generated after the data type and before the function name.
Example code Reverser Notes: When reverse engineering functions that have indirection, all indirection is captured in the C++ Indirection tag definition.
• If the tagged value of the
C++ Initializer List tag definition has been set for a constructor, the set value is used as the initializer text.
Example code Note the C++ Initializer List tag definition should be used only with constructors.
• ·If the Operation is scoped to a Class, Data Type or Interface and the tagged value of the
C++ Non Member tag definition is set to TRUE, the Operation is declared in the owning item's header file but is not a member of the owning class or struct. This Tag Definition is ignored when the Operation is scoped to a Package.
Example code • If the tagged value of the C++ Linkage tag definition has been set, the value is generated as the function's linkage. For example, extern "C".
• If the tagged value of the
C++ Operation Implementation Comment tag definition has been set, the set value is generated as a comment preceding the function implementation in the implementation file.
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.
Example code Note that in the context of an Operation, only the extern value of the C++ Storage Class tag definition should be used.