You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-sources/art-lang/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1172,7 +1172,7 @@ The same transition can be triggered by multiple trigger operations (just like a
1172
1172
1173
1173
Names of classes with state machines by convention start with uppercase, while names of trigger operations and their parameters by convention start with lowercase and use camelCase if the name consists of multiple words.
1174
1174
1175
-
A common design pattern is to let a class-with-statemachine instance be managed by a single capsule instance. This means that the capsule instance is responsible both for creating, using and finally destroying the class-with-statemachine instance. If you follow this pattern it is thread-safe to for example call public member functions defined on the capsule from a transition in the class state machine (or, better, to call non-public member functions by letting the class be a friend of the capsule). This can for example be used as a means for the class state machine to send events through the ports of the capsule (i.e. it can call a capsule member function that sends the event). However, to avoid exposing the full capsule functionality to the class state machine it's recommended to define an interface (i.e. abstract C++ class) which the capsule can implement. This interface can contain only those member functions which the class needs to call on the capsule.
1175
+
A common design pattern is to let a class-with-statemachine instance be managed by a single capsule instance. This means that the capsule instance is responsible both for creating, using and finally destroying the class-with-statemachine instance. If you follow this pattern it is thread-safe to, for example, call public member functions defined on the capsule from a transition in the class state machine (or, better, to call non-public member functions by letting the class be a friend of the capsule). This can for example be used as a means for the class state machine to send events through the ports of the capsule (i.e. it can call a capsule member function that sends the event). However, to avoid exposing the full capsule functionality to the class state machine it's recommended to define an interface (i.e. abstract C++ class) which the capsule can implement. This interface can contain only those member functions which the class needs to call on the capsule.
1176
1176
1177
1177
A class state machine can use the same constructs as a capsule state machine with a few exceptions:
1178
1178
@@ -1188,7 +1188,7 @@ A class with state machine can have the [same code snippets](#capsule_code_snipp
1188
1188
You can find a sample application that uses a class with a state machine [here]({$vars.github.repo$}/tree/main/art-samples/TrafficLight).
1189
1189
1190
1190
### Constructor
1191
-
By default the initial transition of a class state machine executes at the time of constructing the class-with-statemachine instance. This happens because the generated default constructor will call an operation `rtg_init1()` which contains the code from the initial transition. If you want to wait with "starting" the state machine until a later point in time you need to define your own parameterless constructor which doesn't call this function.
1191
+
By default the initial transition of a class state machine will not execute at the time of constructing the class-with-statemachine instance. If you want this to happen, you need to create a constructor with a call to the operation `rtg_init1()` which contains the code from the initial transition. If you want to wait with "starting" the state machine you can instead call `rtg_init1()` at a later point in time, for example from a regular member function of the class.
1192
1192
1193
1193
You can define any constructors you need on a class with a state machine. They are regular C++ constructors and allow to pass initialization data when creating a class-with-statemachine instance. Remember to call the `rtg_init1()` function in all such constructors, if you want the state machine to start at the time of creating the class-with-statemachine instance.
| [inclusionPaths](#inclusionpaths) | List of strings | []
@@ -189,7 +189,13 @@ All rights reserved!
189
189
You can use a multi-line text with empty lines in the beginning and end as shown above, to make the TC more readable. Such empty lines will be ignored by the code generator.
190
190
191
191
### cppCodeStandard
192
-
Defines the C++ language standard to which generated code will conform. The default value for this property is `C++ 17`. Other valid values are `C++ 98`, `C++ 11`, `C++ 14` and `C++ 20`. Note that the latest version of the TargetRTS requires at least C++ 11, so if you use an older code standard you have to set [TargetRTSLocation](#targetrtslocation) to an older version of the TargetRTS that doesn't contain any C++ 11 constructs. If you need to compile generated code with a very old compiler that doesn't even support C++ 98 you can set this preference to `Older than C++ 98`.
192
+
Defines the C++ language standard to which generated C++ code will conform. Valid values for this property are `C++ 98`, `C++ 11`, `C++ 14`, `C++ 17` and `C++ 20`. If you need to compile generated code with a very old compiler that doesn't even support C++ 98 you can set this preference to `Older than C++ 98`.
193
+
194
+
It's recommended to set this property to be explicit about what C++ code standard to use. Doing so ensures that the code generator generates C++ that complies with the selected code standard, and that the C++ compiler also will compile it with the same code standard. The C++ language server will also use the same code standard to ensure a correct behavior when editing C++ in the UI.
195
+
196
+
If you don't set the [cppCodeStandard](#cppcodestandard) property, generated code will comply with C++ 17. But in that case no code standard flag will be passed to the compiler, and instead the compiler's default code standard will be used. Refer to the documentation of your compiler to know which code standard it uses by default. The same is true for the language server; it will use a default code standard.
197
+
198
+
Note that even if the TargetRTS can be compiled also with old C++ compilers, some features will not be available for code standards before C++ 11.
193
199
194
200
### eval
195
201
This is a special property that returns a copy of the TC where all properties with implicit default values have been expanded into real values. It's useful when you want to define a TC property value based on the value of another TC property which has a default value.
| Warning | A TC does not specify which C++ code standard to use | N/A
1737
+
1738
+
The [`cppCodeStandard`](building/transformation-configurations.md#cppcodestandard) property should be set to ensure that the C++ code generator, the C++ compiler and the C++ language server all agree on which code standard that should be used.
1733
1739
1734
1740
## Core Validation Rules
1735
1741
There are certain core rules that run before the semantic validation rules mentioned above. They are responsible for making sure that the Art file is syntactically correct and that all references it contains can be successfully bound to valid Art elements.
0 commit comments