Main Content

getData

Get code mapping configuration for model data

Since R2021a

Description

value = getData(myCPPMappingObj, category, property) returns the code mapping information for the property specified by property and the model data category specified by category.

example

Examples

collapse all

Get the data visibility of model parameters.

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 by using the setData function.

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

Input Arguments

collapse all

C++ code mapping object, returned by a call to either the coder.mapping.utils.create function or the coder.mapping.api.get function.

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

CategoryDescription
'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

Property of model data to access, specified as 'MemberAccessMethod', 'DataVisibility', or 'DataAccess'.

The MemberAccessMethod property specifies how the methods, if any, are generated for the data elements.

The DataVisibility property specifies the visibility (private, public, or protected) of the data category in the generated code.

The DataAccess property specifies whether model elements are stored by value ('Direct') or pointer ('Pointer') in the generated code. Data access is configurable 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

Output Arguments

collapse all

The code mapping property value of the specified category, returned as a character vector.

Version History

Introduced in R2021a