setData
Description
setData(
configures code mapping information for the model data specified by
myCPPMappingObj
, category
, Name,Value
)category
.
Examples
Configure Data Visibility of Model Parameters
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')
value = 'public'
To configure the data visibility, specify the 'DataVisibility'
parameter using the setData
function.
setData(cm, 'ModelParameters', 'DataVisibility', 'private');
Input Arguments
myCPPMappingObj
— C++ code mapping object
CodeMappingCPP
object
C++ code mapping object, returned by a call to either the coder.mapping.utils.create
function or the coder.mapping.api.get
function.
category
— Category of model data
'Inports'
| 'Outports'
| 'ModelParameters'
| 'ModelParameterArguments'
| 'InternalData'
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
Specify optional pairs of arguments as
Name1=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')
MemberAccessMethod
— How methods are generated for data elements
'Method'
| 'Inlined method'
| 'Structure-based method'
| 'Inlined structure-based method'
| 'None'
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. Only
set methods appear for model elements in the
Inports 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 the
Inports 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 aggregate
get and set methods are generated
for each category. |
'Inlined structure-based method' | Data elements appear as a structure in the class. Aggregate
get and set methods defined in their
declaration are generated for each category. |
'None' | If you configure the access of a model element category to
None , get and set
methods do not appear in the generated class. The application code can
directly access the data. |
Data Types: char
| string
DataVisibility
— Visibility of data category in generated code
'private'
| 'public'
| 'protected'
The visibility of the data category in generated code, specified as either
private
, public
, or
protected
. If you configure data elements as
public
, 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
DataAccess
— Access of inports, outports, or model parameter arguments in generated code
'Direct'
(default) | 'Pointer'
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:
'Inports'
whose member access method is set to'Structure-based method'
or'Inlined structure-based method'
.'Outports'
whose member access method is set to'Structure-based method'
or'Inlined structure-based method'
.'ModelParameterArguments'
whose data visibility is set to'private'
(not'Individual Arguments'
).
Data Types: char
| string
Version History
Introduced in R2021a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)