Main Content

setClassNamespace

Set class namespace of model

Description

example

setClassNamespace(myCPPMappingObj, namespace) sets the class namespace of the model in the generated code. Control the scope of the generated code by specifying a namespace for the generated class. In systems that use a model hierarchy, you can specify a different namespace for each model in the hierarchy.

Examples

collapse all

Specify a class namespace for a model and generate C++ code.

Open the model. To access the CodeMappingCPP object associated with the model, use the coder.mapping.api.get function.

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

To specify a namespace for the model in the generated code, use the setClassNamespace function.

setClassNamespace(cm, 'myClassNamespace');

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.

Class namespace of model in the generated code, specified as a character vector. If you do not specify a class namespace, the code generated for the model does not use a namespace.

Data Types: char | string

Introduced in R2021a