QM  6.1.1
Model-Based Design Tool
No Matches
Working with Classes

Working with PackagesWorking with Attributes

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.

QM™ supports classes and inheritance regardless of the target programming language, which currently can be either C or C++. The Application Note "Simple Object-Oriented Programming in C" describes how QP frameworks and the QM code generator implement classes and inheritance in portable ANSI C.
A Class in Model Explorer

Adding a Class

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.

Adding a Class

Class Property Sheet

A Class item can be configured by the Class-Specific Property Sheet.

Class Property Sheet

The class-item property sheet allows you to set the following properties:

Class Name

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 "What's the best approach to naming classes?").

Superclass of a Class

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.

Selecting a Superclass

Class Documentation

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.

Working with PackagesWorking with Attributes