Class mapping for C++ (C++ code)
For each Class that is not nested or non-member, ACS generates a header file (.h) and an implementation file (.cpp), and a class declaration. Nested Classes are generated within the parent class declaration.
ACS ignores Classes that are stereotyped by the «requirement» stereotype, which is available in the SysML Requirements profile.
The class declaration and implementation is derived from the items it owns, properties of the Class, and the tagged values set for Tag Definitions applied by the «C++ Class» stereotype.
Child items:
If a typed Part (Attribute) has an Association that has not been rolled up to the Part's type, ACS generates a nested class that is derived from the Part's type. The nested class defines the Role that is modeled against the Part.
If a Class owns Parts (Attributes or Roles) that are connected through an Association, initialization code is generated in the constructor for the Class.
Reverser Notes: When reverse engineering a class' attributes, the Reverser will reverse engineer the attribute as a Role if all of the following statements are true:
◦ The C++ attribute's data type can be identified as a class in the code being reverse engineered.
◦ The C++ class that is used as a data type can be reverse engineered, that is, it is a child of the root folder or a folder that is mapped to a Modeler Package.
◦ The Reverser cannot match the C++ attribute to an Attribute in the Model.
• If the Class owns Classes, the nested
Classes are generated within the class declaration, unless its C++ Non Member tag definition is set to TRUE.
Example code Reverser Notes: When reverse engineering a file that declares many classes:
◦ The class whose name matches the file name is reversed engineered as the root Class in Modeler.
◦ The other classes in the file are reverse engineered as nested Classes of the root Class in Modeler accordingly.
◦ If in the file a class is not nested in the root class, the Reverser sets the C++ Non Member tag definition (applied by the «C++ Class» stereotype) of the associated Modeler Class to TRUE.
◦ If the name of the code file matches the name of the owning folder, the content of the code file is reverse engineered as items scoped to the Package that is created for the folder.
• If the Class owns Data Types, the nested Data Types are generated within the class declaration, unless its C++ Non Member tag definition is set to TRUE.
• If the Class owns Interfaces, the nested Interfaces are generated within the class declaration, unless its C++ Non Member tag definition is set to TRUE.
If a typed Part (Role) has an Association that has not been rolled up to the Part's type, ACS generates a nested class that is derived from the Part's type. The nested class defines the Role that is modeled against the Part.
If a Class owns Parts (Attributes or Roles) that are connected through an Association, initialization code is generated in the constructor for the Class.
Properties
• The Abstract property is ignored.
• If the
Description property has a value, ACS generates the description as a comment on the line before the class declaration.
Example code • The Formal Template Parameters property is generated as the formal template parameters for a template class.
• The
Name property is generated as the name of the header and implementation files, and the name of the class in the code.
Example code Note that ACS may modify the class name that is added to the code to make it valid for C++. You can specify the exact class name to add to the code through the CODE_GENERATION_NAME property of a Class.
Tell me more...Reverser Notes: When reverse engineering a template class, then Name that is set in Modeler may include the specialization parameters.
Tell me more... • The Persistent property is ignored.
• If the Template property is set to true (Template check box selected on Property Pages), the Class is generated as a template class using the Formal Template Parameters that are specified. For more information about how Template Classes are handled, see:
• If the
Union property is set to true (Template check box selected on Property Pages), the Class is generated as a union.
Example code Tag Definitions:
If you want calls to the Class to be asynchronous but do not want to introduce additional threads, apply the
«C++ Deferred» stereotype to the Class.
Tell me more...The following tag definitions are applied to a Class by the «C++ Class» stereotype:
• If the tagged value of the
C++ Anonymous Itemtag definition is set to TRUE, it means that the class is used as an anonymous type and is generated inline.
Example code Reverser Notes: When reverse engineering a class that is used as an anonymous type, the Reverser creates a Class in Modeler and sets its C++ Anonymous Item tag definition to TRUE. The name of the Class is as follows:
unnamed<integer to make unique>
• If the tagged value of the
C++ Forward Declarations tag definition references any Classes, Data Types, Interfaces and Type Definitions, ACS generates forward declarations to the classes, structs, unions and enums that are generated from those Classes, Data Types, Interfaces and Type Definitions.
Example code Reverser Notes: When reverse engineering a class that has friend classes and friend structs, the C++ Friend tag definition references their associated items if they are modeled in the Model. All other friend class and friend struct declarations are recorded as text through the C++ Friend Text tag definition.
• If the tagged value of the
C++ Forward Declaration Text tag definition has been set, the value is generated as forward declarations.
Example code Reverser Notes: When reverse engineering a class that has friend classes and friend structs, the C++ Friend tag definition references their associated items if they are modeled in the Model. All other friend class and friend struct declarations are recorded as text through the C++ Friend Text tag definition.
• If the tagged value of the
C++ Friend tag definition references any Classes, ACS generates friend declarations for those Classes.
Example code Reverser Notes: When reverse engineering a class that has friend classes, the C++ Friend tag definition references those friend classes if they are modeled in the Model, else the friend class declarations is recorded as text through the C++ Friend Text tag definition.
• ·If the tagged value of the
C++ Friend Texttag definition has been set, the value is generated as friend declarations.
Example code Reverser Notes: When reverse engineering friend declarations, the C++ Friend tag definition is used to reference friend classes that are modeled in the Model. All other friend class and friend function declarations are recorded as text through the C++ Friend Text tag definition.
• If the tagged value of the
C++ Header File Comment tag definition has been set, the value is generated as a header file comment.
Example code • If the tagged value of the
C++ Header Include tag definition has been set, the value is generated at the beginning of the header file so that you can generate your own #includes. Note that you can use Dependencies to generate #includes to Classes, Data Types and Interfaces that are modeled in the Model.
Example code Reverser Notes: When reverse engineering header file #includes the Reverser records the #include as text in the C++ Header Include tag definition.
• If the tagged value of the
C++ Implementation File Comment tag definition has been set, the value is generated as an implementation file comment.
Example code • If the tagged value of the
C++ Implementation Includetag definition has been set, the value is generated at the beginning of the implementation file so that you can generate your own #includes. Note that you can use Dependencies to generate #includes to Classes, Data Types and Interfaces that are modeled in the Model.
Example code Reverser Notes: When reverse engineering implementation file #includes the Reverser records the #include as text in the C++ Header Include tag definition.
• ·If the tagged value of the
C++ Inheritance List tag definition has been set, the value is used to generate the inheritance list for the Class. Note that when a value has been set, the Class' Generalizations are ignored.
Example code Reverser Notes: When reverse engineering class hierarchies the Reverser attempts to model inheritance through Generalizations. If the Reverser cannot model a particular class hierarchy through Generalizations, the Reverser records the complete superclass list as the text of the C++ Inheritance List tag definition.
• ·If the tagged value of the C++ Linkage tag definition has been set, the value is generated as the class' linkage. For example, extern "C".
• ·If the tagged value of the
C++ Non Member tag definition is set to TRUE (applies only to nested Classes), ACS generates the class in the code file created for the root item, but not as part of the class or struct created for the root Modeler item.
Example code • The tagged value of the C++ Specialization Parameters tag definition is ignored when generating code.
Reverser Notes: When reverse engineering a specialized version of a template class, the tagged value of the C++ Specialization Parameters tag definition is set. The use of this tag definition is reserved for future use.
Tell me more... • If the tagged value of the C++ Using Decls tag definition has been set, the value is generated as the using declarations for the class.
If the C++ Using Decls and C++ Using Directives tag definitions are both blank, ACS will generate a 'using namespace std' statement when necessary.
• If the tagged value of the C++ Using Directivestag definition has been set, the value is generated as the using directives for the class.
If the C++ Using Directives and C++ Using Decls tag definitions are both blank, ACS will generate a 'using namespace std' statement when necessary.
• Modeler uses the CPP_HDER tag definition for recording information about generated and reverse engineered header files.
• Modeler uses the CPP_IMPL tag definition for recording information about generated and reverse engineered implementation files.
• If the tagged value of the C++ Generate State Machine tag definition has been set to FALSE, ACS does not generate state machine code for the Class' State Diagram.
The following tag definition is applied to a Class by the «C++ Library» stereotype:
• If a value has been set for the tagged value of the C++ LIB_INCLUDE tag definition, the value is generated as the #include for any classes that use the library, rather than ACS generating a #include based on the library's location in the model.