setData - Configure model data for C++ code generation - MATLAB (original) (raw)

Configure model data for C++ code generation

Since R2021a

Syntax

Description

setData([myCPPMappingObj](#mw%5F4369fd86-8831-4ecc-aecc-c6e008453ed3), [category](#mw%5F176ce099-ac8a-4925-a3bb-7bbd0a59637a), [Name,Value](#namevaluepairarguments)) configures code mapping information for the model data specified bycategory.

example

Examples

collapse all

Configure the data visibility of model parameters to be private.

Open the model. Use the coder.mapping.api.get function to access the CodeMappingCPP object associated with the model.

open_system('CppClassRateBased'); cm = coder.mapping.api.get('CppClassRateBased');

To view the data visibility of the model parameters, use the getData function.

value = getData(cm, 'ModelParameters', 'DataVisibility')

To configure the data visibility, specify the 'DataVisibility' parameter using the setData function.

setData(cm, 'ModelParameters', 'DataVisibility', 'private');

Input Arguments

collapse all

Category of model data to configure, specified as one of these categories.

Category Description
'Inports' Root-level input ports of a model, such as Inport and In Bus Element blocks.
'Outports' Root-level output ports of a model, such as Outport and Out Bus Element blocks.
'ModelParameters' Parameters that are defined within a model, such as parameters in the model workspace. Excludes model arguments.
'ModelParameterArguments' Parameters in the model workspace configured as model arguments. These parameters are exposed at the model block to enable each model instance to provide its own value.
'InternalData' Data elements that are internal to a model, such as block output signals, discrete block states, data stores, and zero-crossing signals.

Data Types: char | string

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: setData(myCPPMappingObj, 'Inports', 'DataVisibility', 'private')

How the methods, if any, are generated for the data elements. This configuration controls how application code can view and modify the class member data.

Member Access Method Description
'Method' The get and set methods for each element in the category appear in the generated class. Onlyset methods appear for model elements in theInports category. Only get methods appear for model elements in the Outports category.
'Inlined method' The get and set methods defined in their declarations appear for each element in a category in the generated class. Only set methods appear for model elements in theInports category. Only get methods appear for model elements in the Outports category.
'Structure-based method' Data elements appear as a structure in the class and aggregateget and set methods are generated for each category.
'Inlined structure-based method' Data elements appear as a structure in the class. Aggregateget and set methods defined in their declaration are generated for each category.
'None' If you configure the access of a model element category toNone, get and set methods do not appear in the generated class. The application code can directly access the data.

Data Types: char | string

The visibility of the data category in generated code, specified as eitherprivate, public, orprotected. If you configure data elements aspublic, they appear as public members of the generated class. If you configure elements as private, they appear as private members of the generated class.

Data Types: char | string

Data access of inports, outports, or model parameter arguments in the generated code, specified as either 'Pointer' or 'Direct'.

You can configure data access for 'Inports','Outports', and 'ModelParameterArguments' categories:

Data Types: char | string

Version History

Introduced in R2021a