Glossary
| Acronym | Definition |
|---|---|
| SPO | Software Production Operation |
| BL | Behavior Layer |
| ML | Middleware Layer |
| BSM | Behavior Specific Middleware |
| TSM | Target Specific Middleware |
Glossary
Referenced Documents
General ConceptsSupported ElementsBelow is an exhaustive list of elements used by the code generator to produce the Code with a summary of the purpose and impact.
Code Generator Specification
This section is divided into two parts:
Files Specifications
Generated code Class elements are composed of (at most) two files for each class:
General requirements releated to file content are described in [2]. <ClassName>.h<ClassName>.h header file describes the content of a class entity. This file declares all the elements associated to a class. File <ClassName>.h is generated for the each UML class and UML interface element involved in the code generation. #include to the file <Top_ClassName>_types.h is generated for the selected UML also known as top Class. <Top_ClassName>_types.h file contains the types used at interface with top UML class. #include to the file internal_types.h is generated. internal_types.h file contains the types used in the selected UML class and its sub-elements. #include "internal_types.h" Example: Includes
The header declares, in this order: the
A forward declaration announces the existence of a type without disclosing its definition. Every type that is only announced in the header is included in the corresponding implementation file, so the generated code never depends on an indirect inclusion to compile. The namespace is used in the forward declaration if any. See Semantic Code Specifications for more information.
/**********************************************************************************
* Forward declaration(s)
**********************************************************************************/
/* Forward declaration of LockManager */
namespace Car::DoorMngt {
class LockManager;
}
Example: Forward declaration
For every other type the current class depends on — through
inheritance, composition, aggregation, association or usage —
the header generates either an
#include "LockableElement.h" \* MISRA rule 12.3 violation */ Example: Additional includes See Semantic Code Specifications for more information. The namespace is declared here if any. See Semantic Code Specifications for more information. If any referenced class is declared in a namespace, then this namespace is declared in the using namespace section. See Semantic Code Specifications for more information. A user-specific section is generated to insert additional includes. The class is declared using the regular cpp declaration mechanism. For more information on the declaration, see the dedicated section in Semantic Code Specifications.
/** @generated from: <class uuid> */
namespace Car::DoorMngt {
using namespace Car::DoorMngt;
/* BEG_USER_CODE(header) do not remove */
/* Add your includes here */
/* END_USER_CODE(header) do not remove */
/** @generated_from _19_0_3_16600ad_1654593306068_127462_42636 */
class LockManager {
<CLASS MEMBER DECLARATION>
};
} //Car::DoorMngt
Example: Class declaration <Class name>.cpp<ClassName>.cpp source file implements functions declared in thecorresponding header file for a class. File <ClassName>.cpp is generated for the each UML class element involved in the code generation. #include to the header c file of the corresponding class is inserted. #include "LockableElement.h" Example: Include to header of class The namespace is declared here if any. See Semantic Code Specifications for more information. If any referenced class is declared in a namespace, then this namespace is declared in the using namespace section. See Semantic Code Specifications for more information. The namespace is declared here if any. See Semantic Code Specifications for more information. A user-specific section is generated to insert additional includes and namespaces.
#include "VehicleDoorsManager.h"
namespace Car::DoorMngt {
using namespace std;
using namespace Doors;
using namespace Car::DoorMngt;
/* BEG_USER_CODE(header) do not remove */
/* Add your includes here */
/* END_USER_CODE(header) do not remove */
<CLASS OPERATION IMPLEMENTATION>
Example: class implementation internal_types.hThe internal_type.h file describes the data types used by the properties and the operations in the model. File internal_type.h is generated for the input element which is a Class. General requirements related to file content and structure are described in [2]. #include to the file stdbool_itf.h is generated. stdbool.h file defines bool. Each type used by at interface level Class is generated. See Semantic Code Specifications for more details depending on the elements. #include <stdbool.h> <DATA TYPES DECLARATION> Example: Data types declaration Based on the dependency between types, each type referencing another type is defined after this type Each type definition is protected by a #ifdef, #define, #endif mechanism. Each type is defined via the C typedef mechanism. /********************************************************************** * Data Type <type> definition * @generated_from <uuid> **********************************************************************/ #ifndef <type>_DEFINITION #define <type>_DEFINITION typedef <base_type> <type>; #endif Example: Type declaration Semantic Code Specifications
This section describes the behavior of the code generator depending on the UML element. Package with C++ namespace stereotypeIf a package declares the stereotypes C++ Namespace, then this package is used to declare a namespace in the generated code. ![]() nested namespaces ![]() If c++ version is c++11 namespaces definition shall have this pattern:
namespace A {
namespace B {
…
}
}
If c++ version is greater than c++11, namespaces definition shall have this pattern
namespace A::B {
…
}
If a UML class is created in a package using c++ Namespace stereotype, then its forward declaration is done in a namespace.
namespace Car::DoorMngt {
class LockManager;
}
Example: Class forward declaration with namespace for c++ version greater than c++11
namespace Car {
namespace DoorMngt {
class LockManager;
}
}
Example: Class forward declaration with namespace for c++ version equal to c++11 If a UML class is created in a package using c++ Namespace stereotype, then its declaration is done in a namespace.
namespace Car::DoorMngt {
class LockManager{
};
} //Car::DoorMngt
Example: Class declaration with namespace for c++ version greater than c++11
namespace Car {
namespace DoorMngt {
class LockManager{
};
} //DoorMngt
} //Car
Example: Class declaration with namespace for c++ version equal to c++11 If a UML class is created in a package using c++ Namespace stereotype, then a “using namespace” is inserted in the class which depends on the current class. using namespace Car::DoorMngt; Example: Using namespace declaration Class
If generalization relation is created from a class to another one, then this inheritance relation is reproduced in class declaration. ![]() Visibility inheritance is supported through C++ generalization stereotype on generalization relation
/** @generated_from _2026x_1ca00d3_1768838226712_433953_1328 */
class cls: protected Parent {...
Example: Class declaration with generalization virtual inheritance is supported through C++ generalization stereotype on generalization relation
/** @generated_from _2026x_1ca00d3_1768838226712_433953_1328 */
class cls: public virtual Parent {...
If an operation is set to virtual via CppAnsi profile, generated code has a virtual keyword, and any operation which overrides the virtual one has an override suffix. ![]() In parentClass.h:
class parentClass{
public:
void op1();
virtual void op2();
};
In ChildClass.h:
#include "parentClass.h"
class ChildClass: public parentClass{
public:
void op2() override;
};
If a class uses the stereotype “C++Packed” and the attribute “packed” is set to true and the “compiler” parameter is set to “gcc”, then the generated code has the keyword __attribute__((packed)).
/** @generated from: <class uuid> */
class __attribute__((packed)) A {
};
Example: Class declaration with packed If a class uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the “alignment” attribute is set to a valid value, then the generated code includes the keyword alignas({alignment}).
/** @generated from: <class uuid> */
class alignas({alignment}) A {
};
Example: Class declaration using alignas The keywords alignas({alignment}) and __attribute__((packed)) cannot be applied simultaneously to the same type or variable. When both are defined, the generated code uses alignas({alignment}) and omit __attribute__((packed)). Nested classA Nested class is not supported. A declaration of a class/struct or union may appear within another class. Such declaration declares a nested class. Friend class![]() A friend class relation is configured through a usage relation applying the “C++ Friend” stereotype. A friend class is the target of a usage relation with the stereotype “C++ Friend”. In such case, this class declares the class being the source of relation as a friend of it in the generated code.
class FriendClass{
friend class ClassA;
Example: Property Global functions and variables![]() Global functions and variables are declared by using an unnamed class with “C++Global” stereoptype. Global functions and variables are mapped to operations and attributes into an unnamed class with stereotype «C++Global». The generated files are named global.cpp and global.h. If a global variable uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the “alignment” attribute is set to a valid value, then the generated code includes the keyword alignas({alignment}).
alignas({alignment}) int myGlobalVariable
Example: Global variable declaration using alignas A valid value for “alignment” is either:
Final classA UML class with isLeaf or isFinalSpecialization set to true is generated as final.
class FinalClass final {…}
Composition relation – black diamondCLASS MEMBERS DECLARATION if a composition relation is created from a class to another one, a variable is created in the source class of relation to point to target class. if a composition relation is created from a class to another one as not directional, a pointer variable is created in the target class of relation to point to the source class. ![]()
class A {
/**
* @brief Attribute for composition relation to B:b
* @generated from: _2022x_16600ad_1674047956690_871296_20640
*/
B b;
}
Example: variable in source class
class B {
/**
* @brief Attribute for aggregation relation to A:a
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
A *a;
};
Example: variable in target class for not directional relation if an composition relation exists from a class to another one with the cardinality set to a finite range and upper limit > 1, an array of variables is used. if an composition relation exists from a class to another one with the cardinality set to a range including “*“, a list of variables is used. Aggregation relation – white diamondCLASS MEMBERS DECLARATION if an aggregation relation is created from a class to another one with a cardinality not set or set to 1, a pointer variable is created in the source class of relation to point to target class. if an aggregation relation is created from a class to another one as not directional, a pointer variable is created in the target class of relation to point to the source class. ![]()
class A {
/**
* @brief Attribute for association relation to B:b
* @generated from: _2022x_16600ad_1677666453655_544305_17510
*/
B *b;
};
Example: variable in source class
class B {
/**
* @brief Attribute for aggregation relation to A:a
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
A *a;
};
Example: variable in target class for not directional relation if an aggregation relation exists from a class to another one with the cardinality set to a finite range and upper limit > 1, an array of pointer variables is used. if an aggregation relation exists from a class to another one with the cardinality set to a range including “*“, a list of pointer variables is used. Association relationCLASS MEMBERS DECLARATION if a directed association relation exists from a class to another one with a cardinality not set or set to 1, a pointer variable is created in the source class pointing to the target. if an non-directed association relation exists between 2 classes with the cardinality of the releation not set or set to 1, a pointer variable is created in each class to point to the other class. ![]()
class A {
/**
* @brief Attribute for aggregation relation to B:b
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
B *a;
};
class B {
/**
* @brief Attribute for aggregation relation to A:a
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
A *a;
};
Example: association between 2 classes if an association relation exists between 2 classes, with the cardinality set to a finite range and upper limit > 1, an array of pointer variables is used.
/**
* @generated_brief Private attribute for association relation to array<SuperSetRole2*,2>:superRole2
* @generated_from _2024x_3_c3a0313_1761929246565_867216_1031
*/
array<SuperSetRole2*,2> superRole2;
Example: association to another class with a cardinality [0..2] if an association relation exists between 2 classes, with the cardinality set to a range including “*“, a list of pointer variables is used. Usage relationA usage relation is used to declare that a class usage another element. It is translated into an include of the element in the generated code. A usage relation can be used from a Class to an Interface, another Class or UML artifact. If a Class declares a usage relation to another entity, the corresponding #include is generated.
For a Class object, the generated For an interface object, the generated #include in the context of a Usage relation is generated by using the name of the interface.
For an artifact object, the generated
/********************************************************************************** * Includes declaration **********************************************************************************/ #include <stdio.h>
If the “C++ Include” stereotype applied on the usage relation
carries the value “Class Forward”, a forward declaration of the
used class is generated in the header instead of an
If no “C++ Include” stereotype is applied on the usage relation, the generated include is generated as a user include using …. If a “C++ Include” stereotype is applied on the usage relation, then it is possible to generate a user include using “” or a system include using <…>. either in generated header or implementation. For optimization reasons, two new stereotypes are proposed as replacement of C++Include: “C++ Location“ stereotype applies on usage relation. It supersedes use of “C++ Include“ stereotype. It helps to specify whether used element is targeted for source header or implementation. “C++ Kind“ stereotype applies on UML artifact. It supersedes information eventually set in “C++ Include“ stereotype. Example: artifact with “C++IncludeKind“ set to System in Class.hpp #include <Artifact.hpp> Example: artifact with “C++IncludeKind“ set to User in Class.hpp #include "Artifact.hpp" Example: usage relation with “C++Location“ set to Header in Class.hpp #include "UsedClass.hpp" Example: usage relation with “C++Location“ set to Implementation in Class.cpp #include "UsedClass.hpp" Interface RealizationInterface Realization is implemented thanks to an include to <Interface>.h. See Interface chapter for more information. ![]()
class ifc{
public:
virtual void op()=0;
};
#include "ifc.h"
class clazz: public ifc{
public:
void op() override;
void clazzOp();
};
Property
CLASS MEMBERS DECLARATION Each property declared in a UML class is replicated in the generated code. ![]() A brief description is generated for any property describing type and name of the variable. Additional documentation is generated if the documentation section is field in the model. Type of the property is used as declared in the model. Visibility of the property is used as declared in the model. The default value is set as declared in the model.
public:
/**
* @brief Attribute for composition relation to LockEnum:lockStatus
* This is my documentation for LockControl
* @generated_from _19_0_3_16600ad_1654594678283_920922_43338
*/
LockEnum lockStatus = Closed;
Example: Property Pointer and reference declarationIf a type modifier “*” or “&” is set for a property, then it is used to declare a pointer or a reference to a variable.
public:
/**
* @brief Attribute for composition relation to String:pointerVar
* @generated_from _19_0_3_16600ad_1654594678283_920922_43338
*/
String *pointerVar;
/**
* @brief Attribute for composition relation to Integer:referenceVar
* @generated_from _19_0_3_16600ad_1654594678283_920922_43338
*/
Integer &referenceVar = referenceDefault;
Example: Pointer and reference List declarationIf the multiplicity for a property is set to “*”, the variable is declared as a list. If the multiplicity for a property is set to “*”, using namespace std is added to in top of file in the dedicated section.
/**
* @brief Attribute list<Boolean>:myList
* @generated from: <variable uuid>
*/
list<Boolean> myList;
Example: List declaration Array declaration![]() if the property applies the stereotype “C++ Attributes” and “array” value is configured, variable is generated as an array<Variable Type, length>.
/**
* @brief Attribute for composition relation to array<Integer,2>:configuration
* @generated from: _2022x_2_1ca00d3_1683299592870_873326_17375
*/
array<Integer,2> configuration;
Example: Array declaration Constif isReadOnly attribute of the property is set to true, the variable is declared as a const variable.
/**
* @brief Attribute Boolean:debugMode
* @generated_from _2022x_2_1ca00d3_1686732945801_136413_17517
*/
const Boolean debugMode;
Example: const declaration Staticif isStatic attribute of the property is set to true, the variable is declared as a static variable.
/**
* @brief Attribute Boolean:debugMode
* @generated_from _2022x_2_1ca00d3_1686732945801_136413_17517
*/
static Boolean debugMode;
Example: static declaration PackedIf the property uses the stereotype “C++Packed” and the attribute “packed” is set to true and the “compiler” parameter is set on “gcc”, then the generated code shall have the keyword __attribute__((packed)), except for bitfield, pointer and reference properties.
public:
/**
* @brief <brief description>
* @generated_from <class uuid>
*/
int __attribute__((packed)) myProperty;
Example: Property declaration with packed AlignedIf the property uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the attribute “alignment” is set to a valid value, then the generated code includes the keyword alignas({alignment}) except for bitfield and reference properties.
public:
/**
* @brief <brief description>
* @generated_from <class uuid>
*/
alignas({alignment}) int myProperty1;
alignas({alignment}) int *myProperty2;
Example: Property declaration using alignas A valid value for “alignment” is either:
Operation
CLASS MEMBERS DECLARATION ![]() Each operation declared in a UML Class is generated in the header file. A brief description is generated for any property describing type and name of the variable. Additional documentation is generated if the documentation section is field in the model. Visibility of the operation is used as declared in the model.
public:
/** @generated_from _2022x_16600ad_1673944282153_805594_18447 */
Boolean lockDoors();
Example: Operation Default ConstructorA default constructor is automatically declared without any parameter for class object even if not declared in the class in the following cases:
class Door{
/**
* @brief Constructor
* @generated from: <function uuid>
*/
Door();
};
Example: Constructor User-specific ConstructorIf an operation uses the stereotype “C++ Constructor” or “Create” or “constructor” then the function is declared as a constructor in header file. Explicit constructor![]() If an operation uses the stereotype “C++ Constructor” and attribute Explicit is set to true then the function is generated as an explicit constructor.
class Door{
/**
* @brief Constructor
* @generated from: <function uuid>
*/
explicit Door();
};
Example: Explicit constructor DestructorIf an operation uses the stereotype “C++ Destructor” then the function is declared as a destructor in header file. If an operation uses the stereotype “Destroy” then the function is declared as a destructor in header file. If an operation uses the stereotype “destructor” then the function is declared as a destructor in header file.
class Door{
/**
* @brief Destructor
* @generated from: <function uuid>
*/
~Door();
};
Example: Destructor A UML abstract class or UML interface without any declared operation has a pure virtual destructor declared in the generated C++ class public: /** * @generated_brief Public operation ~AbstractEmptyClass * @reverse_ignore */ virtual ~AbstractEmptyClass() = 0; ...
Getter / setterGetter/setter can be configured through the contextual menu: ![]() ![]() Getter and setter are declared in a header file for each function declared accordingly in the model.
class Door {
/**
* @brief Setter method for attribute WindowPosition
* this is an example of documentation from model
* @generated from: _2022x_16600ad_1677147742721_382790_17804
*/
void setWindowPosition(ControlEnum /*in*/ windowPosition);
/**
* @brief Getter method for attribute WindowPosition
* @generated from: _2022x_16600ad_1677147745041_9971_17808
*/
ControlEnum getWindowPosition();
};
Example: getter & setter InlineIf an operation uses the stereotype “C++ operation” and attribute Inline is set to true then the function is generated as an inline function.
/** @generated_from _2022x_16600ad_1677575910398_769750_17568 */
inline bool isLocked();
Example: Inline Virtual/NoVirtualAny operation has a virtual keyword applied, unless a C++ANSI_novirtual stereotype is applied. ![]() /** * @generated_brief Public operation op * @generated_from _2026x_1_1ca00d3_1770811110998_990206_1732 */ virtual void op(); The C++_novirtual stereotype inhibits the default enabling of a virtual mechanism for an operation. When applied to a package, all operations that belong to subclasses are not virtual. When applied to a class, all class operations is not virtual When applied to an operation, this operation is not virtual ![]()
/**
* @generated_brief Public operation op
* @generated_from _2026x_1_1ca00d3_1770811110998_990206_1732
*/
void op();
If an operation uses the stereotype “C++ operation” and the attribute Virtual is set to true then the function is generated as a virtual function. It supersedes C++_novirtual stereotype.
/** @generated_from _2022x_16600ad_1677248284517_509336_17224 */
virtual void virtualOperation();
Example: Virtual A virtual attribute set to an operation superseeds C++ novirtual mechanism. If an operation uses the stereotype “C++ constructor” and the attribute Virtual is set to true, then the function is generated without the keyword “virtual”. “Virtual” is not allowed for C++ constructors. An operation has the override keyword if its source UML operation refers another UML operation through a ‘redefined operation’ or sync element attribute. ![]()
class Parent {
public:
/**
* @generated_brief Public operation op
* @generated_from _2026x_1ca00d3_1760023469726_951385_1331
*/
virtual void op();
class Child: public Parent {
public:
/**
* @generated_brief Public operation op
* @generated_from _2026x_1ca00d3_1760081097259_183445_1353
*/
void op() override;
Pure VirtualIf an operation uses abstract attribute set to true, then the function is generated as a pure virtual function. A virtual function has no implementation in source code.
/** @generated_from _2022x_16600ad_1677248284517_509336_17224 */
virtual void virtualOperation()=0;
Example: Pure Virtual An operation generated from a UML Interface is pure virtual. VolatileIf an operation uses the stereotype “C++ operation” and the attribute Volatile is set to true then the function is generated as a volatile function.
/** @generated_from _2022x_16600ad_1677248284517_509336_17224 */
void volatileOperation() volatile;
Example: volatile StaticIf the attribute isStatic is set to true for an operation then the operation is generated as a static function.
/**
* @generated_brief Public operation staticFunction
* @generated_from _2022x_2_1ca00d3_1697710303899_846231_4060
*/
static Integer staticFunction();
ConstIf the attribute isQuery is set to true for an operation, then the operation is generated as a const function.
/** @generated_from _2022x_16600ad_1677248284517_509336_17224 */
void ConstFunction() const;
Example: const Friend![]() A friend operation relation is configured through a usage relation applying the “C++ Friend” stereotype from an operation to a class. A friend class is the target of a usage relation with the stereotype “C++ Friend”. In such a case, this class declares the operation being the source of relation as a friend operation in the generated code. This requirement is not supported. See validation rules.
class FriendClass{
friend class ClassA;
Example: Property Function pointerFunction pointer not yet supported. Add a validation rule. OperatorOperator not yet supported. Add a validation rule. ExceptionException not yet supported. Add a validation rule. Operation behaviorA behavior can be attached to an operation to represent its implementation. This can be done by using the “Method” attribute of an operation. If an is activity assigned to an operation, then a variable typed with the struct representing the activity is declared in the private section of the class containing the operation.
class SeatController{
private:
/**
* Instance of Activity associated to operation keyPressed
*/
keyPressed_struct keyPressed_Activity;
}
Example: Operation with activity CLASS OPERATION IMPLEMENTATION Each operation declared in a UML Class is generated in the source file. ![]() A brief description is generated for any property describing the type and name of the variable. Additional documentation is generated if the documentation section is field in the model. User code section is inserted in operation to let the user fills his behavior. If any, a default return code is inserted in the user code section.
/** @generated_from _2022x_16600ad_1673944282153_805594_18447 */
Boolean VehicleDoorsManager::lockDoors(){
/* BEG_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
/* Add your code here */
return 0;
/* END_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
}
Example: Operation implementation Default ConstructorA default constructor is automatically generated without any parameter for a class object even if not declared in the class in the following cases:
A default constructor is automatically generated to allow proper initialization of behaviors.
/**
* Constructor generated automatically to initialize data structure
* @generated_from _2024x_2_16600ad_1719557654818_342936_1322
*/
A::A(){
/* Call hierarchical constructors */
myOp_struct_ctor(&A_myOp_Activity, this);
}
Example: Default Constructor User-specific ConstructorIf an operation uses the stereotype “C++ Constructor” or “Create” or “constructor” then the function is generated as a constructor in the source code.
/**
* @brief Constructor
* @generated_from _2022x_16600ad_1677659222512_81989_17260
*/
Door::Door(){
/* BEG_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
/* Add your code here */
/* END_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
}
Example: Constructor Explicit ConstructorIf an operation uses the stereotype “C++ Constructor” and attribute Explicit is set to true, then the function is generated as a regular constructor. Note that the explicit keyword only appears within the class definition. See: https://en.cppreference.com/w/cpp/language/explicit
/**
* @brief Constructor
* @generated_from _2022x_16600ad_1677659222512_81989_17260
*/
Door::Door(){
/* BEG_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
/* Add your code here */
/* END_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
}
Example: Explicit constructor generated as standard constructor Getter/SetterGetter and setter are generated for each function declared accordingly in the model and content is automatically generated to access or modify the associated attribute.
/**
* @brief Setter method for attribute WindowPosition
* @generated_from _2022x_16600ad_1677147742721_382790_17804
*/
void Door::setWindowPosition(ControlEnum /*in*/ windowPosition){
WindowPosition = windowPosition;
}
/**
* @brief Getter method for attribute WindowPosition
* @generated_from _2022x_16600ad_1677147745041_9971_17808
*/
ControlEnum Door::getWindowPosition(){
return WindowPosition;
}
Example: getter & setter InlineIf an operation uses the stereotype “C++ operation” and the attribute Inline is set to true, then the function is generated as an inline function.
/** @generated_from _2022x_16600ad_1677575910398_769750_17568 */
inline bool LockableElement::isLocked(){
/* BEG_USER_CODE(_2022x_16600ad_1677575910398_769750_17568) do not remove */
/* Add your code here */
return 0;
/* END_USER_CODE(_2022x_16600ad_1677575910398_769750_17568) do not remove */
}
Example: Inline Operation behaviorIf an opaque behavior is assigned to an operation, then this opaque behavior is replicated in the operation body.
void ClassA::OperationWithBeh(){
/* BEG_USER_CODE(_2024x_1ca00d3_1700818869010_751926_3013) do not remove */
FriendClass c;
c.privateOp();
/* END_USER_CODE(_2024x_1ca00d3_1700818869010_751926_3013) do not remove */
}
Example: Operation with behavior If an activity is assigned to an operation, then this activity is invoked in the operation body. The invoke phase consist of a first initialization performed once followed by the call of the activity code.
/**
* @brief Public operation keyPressed
* @generated_from _2024x_3_16600ad_1741101627358_33745_20297
*/
void SeatController::keyPressed(Key /*in*/ key) {
static Boolean first = true;
if(first){
_basic_keyPressed_init(&keyPressed_Activity);
keyPressed_Activity.classifier = this;
first = false;
}
keyPressed_Activity.key=key;
keyPressed_Activity.WALL_CLOCK = tal_GetTime();
(void)_basic_keyPressed(&keyPressed_Activity);
}
Example: Operation with activity Final operationA UML operation with attribute isLeaf set to true generates a final method. void op() final Parameter
The type of parameter of operation with direction set as “return” is used as return type of the operation. The parameter of operation with direction set as “in” or “out” or “inout” is used as parameter of the operation. The type of parameter of operation with direction set as “in” or “out” or “inout” is used in parameter declaration of the operation. The direction “in” or “out” or “inout” of a parameter is used for documentation purposes. A parameter with direction set to in is declared as const. ![]()
/**
* @generated_brief Public operation op
@generated_from 2026x_1ca00d3_1768838229586_841776_1329
*/
virtual void op(const Integer /*in*/ x, Boolean /*in*/ y);
Example: parameters Pointer declarationIf a type modifier “*” is set for a parameter, then it is used to declare a pointer to a variable. /** * @generated_from _2022x_16600ad_1677147742721_382790_17804 */ void Door_setWindowPosition(Door* self, ControlEnum* /*out*/ windowPosition); Example: Pointer List declarationIf the multiplicity for a property is set to “*”, the parameter is declared as a list. If the multiplicity for a property is set to “*”, using namespace std is added to in top of file in the dedicated section.
/** @generated from: _2022x_2_1ca00d3_1687790982594_316859_17456 */
list<HistoryEntry> getHistoryRange(Integer /*in*/ from, Integer /*in*/ to);
/** @generated from: _2022x_2_1ca00d3_1687792555350_758911_17497 */
void getdoorIdHistory(Integer /*in*/ doorId, list<LockEnum> /*out*/ actions);
Example: parameter as list Array declarationif the parameter applies the stereotypes “C++ Attributes” and the “array” value is configured, a parameter is generated as an array<Parameter Type, length>. ![]()
/** @generated from: _2022x_2_1ca00d3_1685001263779_527188_17508 */
void setConfiguration(array<Integer,2> /*in*/ configuration);
Example: parameter as array Variable length parameter listA variable length parameter list is not yet supported. Add a validation rule. Dependency relationIn case of a dependency relation between two objects (UML Class or UML Interfaces), the target elements of the relation are automatically generated if the source of the relation is part of the generation. Flow PortA variable is expected to be created in the Class to store the values exchanged through the Flow Ports of the Class. For each Flow Port, a variable typed with the type referenced by the Flow Port is generated. For each Flow Port, a variable named with the name of the Port and a suffix “_data” is generated.
public:
/**
* Data for Flow Port flowPort
* @generated from: _19_0_3_16600ad_1654593633874_525666_43081
*/
Integer flowPort_data;
Example: Flow Port variable Proxy Port & Interface Block and Flow PropertyA variable is expected to be created in the Class to store the values exchanged through the Flow Properties transmitted through proxy Ports of the Class. For each Flow Property contained in an Interface Block that is referenced by a Proxy Port, a variable typed with the type referenced by the Flow Property is generated. For each Flow Property contained in an Interface Block that is referenced by a Proxy Port, a variable named with the name of the Proxy Port, an “_” and the Flow Property name is generated.
public:
/**
* Data for Flow Property myFlowProperty of Interface Block myItf in Proxy Port myPort
* @generated from: _19_0_3_16600ad_1654593633874_525666_43081
* @generated from: _19_0_3_16600ad_1654593633874_525666_43082
* @generated from: _19_0_3_16600ad_1654593633874_525666_43083
*/
Integer myPort_myItf;
Example: Flow Property variable Port & Interface & PropertyA variable is expected to be created in the Class to store the values exchanged through the Properties transmitted through Ports of the Class. For each Property contained in an Interface that is referenced by a Port, a variable typed with the type referenced by the Property is generated. For each Property contained in an Interface that is referenced by a Port, a variable named with the name of the Port, an “_” and the Property name is generated.
public:
/**
* Data for Property myFlowProperty of Interface myItf in Port myPort
* @generated from: _19_0_3_16600ad_1654593633874_525666_43081
* @generated from: _19_0_3_16600ad_1654593633874_525666_43082
* @generated from: _19_0_3_16600ad_1654593633874_525666_43083
*/
Integer myPort_myItf;
Example: Flow Property variable InterfaceA UML interface is represented by a C++ class with pure virtual operations. As a rationale, only a header file is generated. A file named <interface name>.h is created, except for C++ standard Library headers. Classifier BehaviorCLASS MEMBERS DECLARATION A variable typed with the structure of the behavior is generated for the Classifier behavior with public visibility. See [4] for more information on the structure naming. All structures are named through the same pattern. A variable having the name of the behavior is generated for the Classifier behavior with public visibility.
public:
/**
* Data for Behavior Statemachine
* @generated from: _19_0_3_16600ad_1654593633874_525666_43081
*/
Statemachine_struct Statemachine;
Example: Classifier behavior variable DataType & Value Type & Enumeration
DataTypes generation in class are not yet supported. A type can be a redefinition of an existing type by using a Generalization relation. ![]() Data Types and Value Types are used to type the data contained in classes. DATA TYPES DECLARATION Each Data Type or Value Type that is referenced by a Property, Parameter, or Operation argument are expected to be defined in <ClassName>_internal_type.h Primitive TypeData types defined in C++ ANSI profile are supported. No typedef needs to be generated. ![]() Two additional ANSI types are also provided: ‘short’ and ‘unsigned short’. Data types defined in UML Standard Profile/MagicDraw profile/datatypes are supported. typedef is generated or not according to following requirements. ![]() Datatypes defined in “UML Standard Profile/MagicDraw profile/datatypes” “Color”, “StructuredExpression”, “date” and “XML” are not supported. Data types defined in “UML Standard Profile/UML 2 Metamodel/Primitive Types” are supported. typedef is generated according to following requirements. ![]() Datatype defined in “UML Standard Profile/UML 2 Metamodel/Primitive Types” “UnlimitedNatural” is not supported.* ![]() Data types defined in “SysML/Libraries/PrimitiveValueTypes” are supported. typedef is generated according to the following requirements. ![]() Datatypes defined in “SysML/Libraries/PrimitiveValueTypes” “Complex” and “Number” are not supported. A Data Type or a Value Type having one of the following names are not defined:
Primitive types provided by <stdint.h> or <csdtint> are supported:
Primitive types provided by <math.h> or <cmath> are supported:
If an Integer type of the following profiles is referenced directly or indirectly in the design, an Integer type will be generated:
An integer is defined as an int. #ifndef Integer_DEFINITION #define Integer_DEFINITION typedef int Integer; #endif Example: Integer type declaration If a Boolean type of the following profiles is referenced directly or indirectly in the design, a Boolean type is generated:
A Boolean is defined as a bool. #ifndef Boolean_DEFINITION #define Boolean_DEFINITION typedef bool Boolean; #endif Example: Boolean type declaration If a Real type of the following profiles is referenced directly or indirectly in the design, a Real type is generated:
Real is defined as a double. #ifndef Real_DEFINITION #define Real_DEFINITION typedef double Real; #endif Example: Real type declaration If a String type of the following profiles is referenced directly or indirectly in the design, a String type is generated:
A String is defined as a char*. #ifndef String_DEFINITION #define String_DEFINITION typedef char* String; #endif Example: String type declaration If a primitive type uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the “compiler” parameter is set to “gcc”, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}).
alignas({alignment}) typedef int alignedInteger;
Example: Primitive type declaration using alignas A valid value for “alignment” is either:
Array Type![]() An array is generated when a property, a parameter or a type references another type with a multiplicity greater than 1. An array is defined with a naming convention as follows: Array_<size>_<referencedType>. /********************************************************************** * Data Type Array_3_Integer definition **********************************************************************/ #ifndef Array_3_Integer_DEFINITION #define Array_3_Integer_DEFINITION typedef Integer Array_3_Integer[3]; #endif /* Array_3_Integer */ Example: Array definition in model If an array type uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the “compiler” parameter is set to “gcc”, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}).
alignas({alignment}) typedef int Array_3_Integer[3];
Example: Array type declaration using alignas A valid value for “alignment” is either:
Structure Type![]() A struct is defined for a value type or a data type containing one or multiple properties.
/**********************************************************************
* Data Type Struct definition
**********************************************************************/
#ifndef Struct_DEFINITION
#define Struct_DEFINITION
typedef struct {
unsigned int data1;
double data2;
bool data3;
} Struct;
#endif /* Struct */
Example: structure definition If the structure type uses the stereotype “C++Packed” and the attribute “packed” is set to true and the “compiler” parameter is set on “gcc”, then the generated code shall have the keyword __attribute__((packed)).
typedef struct __attribute__((packed)) {
int attribute1;
int attribute2;
} StructType;
Example: Structure declaration with packed If the property of the structure type uses the stereotype “C++Packed” and the attribute “packed” is set to true and the “compiler” parameter is set on “gcc”, then the generated code is to have keyword the __attribute__((packed)), except for bitfield, pointer, and reference properties.
typedef struct {
int attribute1;
struct OtherStrucType __attribute__((packed)) attribute2;
} StructType;
Example: Property structure declaration with packed If the structure type uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}).
typedef struct alignas({alignment}) {
int attribute1;
int attribute2;
} StructType;
Example: Structure declaration using alignas A valid value for “alignment” is either:
If the property of the structure type uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}) except for bitfield and reference properties.
typedef struct {
int attribute1;
alignas({alignment}) struct OtherStrucType attribute2;
alignas(16) int *attribute3;
} StructType;
Example: Property structure declaration using alignas A valid value for “alignment” is either:
Enumeration TypeAn enum is identified as an Enumeration in the design. ![]() An enum is defined for an enumeration.
/**********************************************************************
* Data Type ControlEnum definition
* @generated_from _2022x_16600ad_1673975868491_889391_20271
**********************************************************************/
#ifndef ControlEnum_DEFINITION
#define ControlEnum_DEFINITION
enum ControlEnum {
Idle,
Open,
Close
};
#endif /* ControlEnum */
If the enumeration uses the stereotype “C++Packed” and the attribute “packed” is set to true and the “compiler” parameter is set on “gcc”, then the generated code shall have the keyword __attribute__((packed)).
enum __attribute__((packed)) EnumPacked{
literal1,
literal2
};
Example: Enumeration declaration with packed If an enumeration literal has the attribute “value” of C++ANSI Profile defined, then the value of that attribute is used in the generated code. The “value” attribute must be a signed integer.
enum EnumPacked{
literal1 = 1,
literal2
};
Example: Enumeration declaration with attribute “value” defined If an enumeration literal has a specification of kind ‘Literal Integer’ defined, then the value of that specification is used in the generated code. If an enumeration literal has both a specification and the attribute “value” of C++ANSI Profile defined, then the “value” is used in the generated code instead of the specification. If neither the specification nor the “value” attribute of the C++ ANSI Profile is defined for an enumeration literal, then the name of the enumeration literal is used in the generated code. If the enumeration uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}).
enum alignas({alignment}) MyEnumeration {
literal1,
literal2
};
Example: Enumeration declaration using alignas A valid value for “alignment” is either:
Union TypeIf a union uses the stereotype “C++Packed”, and the attribute “packed” is set to true, and the “compiler” parameter is set to “gcc”, then the generated code is to have the keyword __attribute__((packed)).
typedef union __attribute__((packed)) MyUnion {
int i;
double d;
} MyUnionType;
Example: Union declaration using packed If a union uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}).
typedef alignas({alignment}) union MyUnion {
int i;
double d;
};
Example: Union declaration using alignas A valid value for “alignment” is either:
SignalDATA TYPES DECLARATION Each Signal that is received or produced by any behavior is expected to be defined in <ClassName>_internal_type.h If a component contains one or multiple signals, a trigger_type is generated. /********************************************************************** * Data Type trigger_type definition **********************************************************************/ #ifndef trigger_type_DEFINITION #define trigger_type_DEFINITION typedef bool trigger_type; #endif /* trigger_type */ If a signal references one or multiple properties, a dedicated structure is generated for the data transmitted with the signal.
/**********************************************************************
* Data Type Signal definition
**********************************************************************/
#ifndef Signal_DEFINITION
#define Signal_DEFINITION
typedef struct {
Integer s1;
Integer s2;
} Signal;
#endif /* Signal */
Example: Signal content declaration A signal type is declared through a structure named SignalEvent_<signal_nme>l_type. This structure contains at least one trigger field with type trigger_type to store the event activation. If a signal references one or multiple properties, an addition field named <signal_name> is added to the structure.
/**********************************************************************
* Data Type SignalEvent_Signal_type definition
**********************************************************************/
#ifndef SignalEvent_Signal_type_DEFINITION
#define SignalEvent_Signal_type_DEFINITION
typedef struct {
trigger_type trigger;
Signal data;
} SignalEvent_Signal_type;
#endif /* SignalEvent_Signal_type */
If the signal uses the stereotype “C++Packed” and the attribute “packed” is set to true and the “compiler” parameter is set on “gcc”, then the generated code is to have the keyword __attribute__((packed)).
typedef struct __attribute__((packed)) {
trigger_type trigger;
Signal data;
} SignalEvent_Signal_type;
Example: Signal declaration with packed If the property of the signal uses the stereotype “C++Packed” and the attribute “packed” is set to true and the “compiler” parameter is set on “gcc”, then the generated code is to have the keyword __attribute__((packed)), except for bitfield, pointer and reference properties.
typedef struct {
trigger_type trigger;
Signal __attribute__((packed)) data;
} SignalEvent_Signal_type;
Example: Property signal declaration with packed If the signal uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}).
typedef struct alignas({alignment}) {
trigger_type trigger;
Signal data;
} SignalEvent_Signal_type;
Example: Signal declaration using alignas A valid value for “alignment” is either:
If the property of the signal uses the stereotype “C++Aligned”, and the selected C++ version is greater than or equal to C++11, and the attribute “alignment” is set to a valid value, then the generated code is to include the keyword alignas({alignment}) except for bitfield and reference properties.
typedef struct {
trigger_type trigger;
alignas({alignment}) Signal data;
} SignalEvent_Signal_type;
Example: Property signal declaration using alignas A valid value for “alignment” is either:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||