Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > C++ code > Generating C++ code > Generating C++ code > Mapping Information > Mapping information for state diagrams > Data type mapping for C++ (C++ code)
  
Data type mapping for C++ (C++ code)
For each Data Type that is not nested or non-member, ACS generates a header file (.h) and an implementation file (.cpp), and a struct declaration. Nested Data Types are generated within the parent class declaration.
The struct declaration and implementation is derived from the items it owns, properties of the Data Type, and the tagged values set for Tag Definitions applied by the «C++ Class» stereotype.
Child items:
If the Data Type owns Attributes, the Attributes are typically generated within the struct declaration. For Attribute mapping information, see Attribute mapping for C++.
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 Data Type owns Parts (Attributes or Roles) that are connected through an Association, initialization code is generated in the constructor for the Data Type.
Reverser Notes: When reverse engineering a data type's 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.
Note that if the attribute's data type is a collection class or struct, the Cppgen.ini file determines whether the attribute is reverse engineered as a Role or Attribute in the model. For more information, see Collection class mapping for C++.
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 Data Type owns Dependencies, ACS typically generates #includes in the code. For Dependency mapping information, see Dependency mapping for C++ (C++ code)
If the Data Type owns Generalizations that define inheritance, the Generalizations are typically generated as inheritance lists. For Generalization mapping information, see Generalization mapping for C++ (C++ code)
If the Data Type owns Operations, the Operations are typically generated within the struct declaration. For Operation mapping information, see Operation mapping for C++ (C++ code)
If the Data Type owns Roles, the Roles are typically generated as attributes within the struct declaration. For Role mapping information, see Association and Role mapping for C++(C++ code)
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 Data Type owns Parts (Attributes or Roles) that are connected through an Association, initialization code is generated in the constructor for the Data Type.
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 struct declaration.
The Formal Template Parameters property is generated as the formal template parameters for a template struct.
The Name property is generated as the name of the header and implementation files, and the name of the struct in the code.
Note that ACS may modify the struct name that is added to the code to make it valid for C++. You can specify the exact struct name to add to the code through the CODE_GENERATION_NAME property of a Data Type. Tell me more...
Reverser Notes: When reverse engineering a template struct, 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 Data Type is generated as a template struct using the Formal Template Parameters that are specified. For more information about how Template Data Types are handled, see the following topics:
Template class specialization mapping for C++ (C++ code)
Template class derivation mapping for C++ (C++ code)
Tag Definitions:
The following tag definitions are applied to a Data Type by the «C++ Class» stereotype:
If the tagged value of the C++ Anonymous Itemtag definition is set to TRUE, it means that the struct is used as an anonymous type and is generated inline.
Reverser Notes: When reverse engineering a struct that is used as an anonymous type, the Reverser creates a Data Type in Modeler and sets its C++ Anonymous Item tag definition to TRUE. The name of the Data Type 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.
Reverser Notes: When reverse engineering a struct that has forward declarations, the C++ Forward Declaration tag definition references those Classes, Data Types, Interfaces and Type Definitions if they are modeled in the Model, else the forward declarations are recorded as text through the C++ Forward Declarations 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.
Reverser Notes: When reverse engineering a struct that has forward declarations, the C++ Forward Declaration tag definition references those Classes, Data Types, Interfaces and Type Definitions if they are modeled in the Model, else the forward declarations are recorded as text through the C++ Forward Declarations Text tag definition.
If the tagged value of the C++ Friend tag definition references any Classes, Data Types and Interfaces, ACS generates friend declarations for those items.
Reverser Notes: When reverse engineering a struct 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 Text tag definition has been set, the value is generated as friend declarations.
Reverser Notes: When reverse engineering a struct 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++ Header File Comment tag definition has been set, the value is generated as a header file comment.
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.
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.
If the tagged value of the C++ Implementation Include tag 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.
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 Data Type. Note that when a value has been set, the Data Type's Generalizations are ignored.
Reverser Notes: When reverse engineering struct hierarchies the Reverser attempts to model inheritance through Generalizations. If the Reverser cannot model a particular struct hierarchy through Generalizations, the Reverser records the complete superstruct 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 struct's linkage. For example, extern "C".
If the tagged value of the C++ Non Member tag definition is set to TRUE (applies only to nested Data Types), ACS generates the struct in the code file created for the root item, but not as part of the class or struct created for the root Modeler item.
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 struct, 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 struct.
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 Directives tag definition has been set, the value is generated as the using directives for the struct.
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.
The C++ Generate State Machine tag definition does not apply to Data Types.
The following tag definition is applied to a Data Type 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.