QM  6.1.2
Model-Based Design Tool
Loading...
Searching...
No Matches
Working with Attributes

Working with ClassesWorking with Class Operations

An attribute defines a variable that can be attached to the instances of a class (see Class Attributes) or to a package (see Free Attributes).

Class Attributes

Attributes attached to a class are present in each instance of the class, except for a static class attribute, which exists in one copy only, regardless of the number of class instances. In C/C++, non-static class attributes correspond to data members of a struct/class.

Adding a Class Attribute

A class attribute can only be added to a Class. To add a class attribute, in the Model Explorer right-click on the Class to which you want to add a new class attribute and select Add Attribute from the popup menu.

Adding a Class Attribute

Class Attribute Property Sheet

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

Class Attribute Property Sheet

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

  • attribute name (NOTE: name can be followed by the array dimension for arrays of attributes)
  • attribute type drop-down box (NOTE: accepts also user-supplied types)
  • attribute visibility drop-down box with options: public, protected, private
  • static checkbox (for designating a class attribute as a static class attribute)
  • attribute documentation for documenting the attribute (see also generate comments)

Free Attributes

Attributes attached to a package (as opposed to a class) are called free attributes. In C/C++, such free attributes correspond to variables defined directly at file scope (either static variables or a global variables).

Adding a Free Attribute

A free attribute can only be added to a Package. To add a free attribute, in the Model Explorer right-click on the Package to which you want to add a new free attribute and select Add Attribute from the popup menu.

Adding a Class Attribute

Free Attribute Property Sheet

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

Free Attribute Property Sheets (simple initializer--left, and array initializer--right)

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

  • attribute name (NOTE: name can be followed by the array dimension for arrays of attributes)
  • attribute type drop-down box (NOTE: accepts also user-supplied types)
  • attribute documentation for documenting the attribute (see also generate comments)
  • attribute initializer for optional initialization of the free attribute (see also free attribute definition)

Working with ClassesWorking with Class Operations