Control Generation of C++ Class Interfaces

By setting the model configuration parameter Code interface packaging to C++ class, you can generate a C++ class interface to model code. The generated interface encapsulates required model data into C++ class attributes and model entry-point functions into C++ class methods. The benefits of C++ class encapsulation include:

  • Greater control over access to model data

  • Ability to multiply instantiate model classes

  • Easier integration of model code into C++ programming environments

C++ class encapsulation also works for right-click builds of nonvirtual subsystems. (For information on requirements that apply, see Configure C++ Class Interfaces for Nonvirtual Subsystems.)

To generate C++ class interfaces in model code:

  1. Configure your model to use an ERT-based system target file provided by MathWorks®.

  2. In the Configuration Parameters dialog box, set Language to C++.

  3. Optionally, configure related C++ class interface settings for your model code, using a graphical user interface (GUI) or application programming interface (API).

  4. Generate model code and examine the results.

To get started with an example, see Simple Use of C++ Class Control. For more details about configuring C++ class interfaces for model code, see Customize C++ Class Interfaces Using Graphical Interfaces and Customize C++ Class Interfaces Programmatically. For limitations that apply, see C++ Class Interface Control Limitations.

For an example of C++ class code generation, see Customize Interface to Generated C++ Code That Is Called By C Code.

Related Topics