A class↑ groups together attributes and operations available to all instances of the class (objects). A class can also inherit↑ from another class (called the superclass).
Classes are the main entities from which you build your models in QM™. Also, in QM™, only a class can have a State Machine.
A Class can only be added to a Package. To add a Class, in the Model Explorer right-click on the Package to which you want to add a new Class and select Add Class from the popup menu.
A Class item can be configured by the Class-Specific Property Sheet.
The class-item property sheet allows you to set the following properties:
The class name should be a valid name of a C++ class
or a C struct
. Typically, you should strive for a short and punchy name, typically a noun that captures the nature of the objects of this class. For example, a class that encapsulates a motor controller could be named Motor
. (For more ideas about naming classes, see the discussion of the StackOverflow question <a target="_blank" rel="noopener" href="http://stackoverflow.com/questions/38019/whats-the-best-approach-to-naming-classes"">What's the best approach to naming classes?"↑).
A class can optionally inherit a superclass. A superclass can be any of the already defined classes, which specifically include classes provided in the QP Framework Item. The following screen shot shows an expanded drop-down box of existing classes, from which you can choose the superclass. Please note that the classes listed in the drop-box use the Fully-Qualified Names, that is, names that are prefixed with the package name(s), such as qpc::QActive
.
The documentation box in the Class Property Sheet allows you to provide documentation to the class. The QM code generator parses the documentation box and can generate comments from it in the auto-generated code.