Main Content

getClassNamespace

Get class namespace for a model

Description

example

namespace = getClassNamespace(myCPPMappingObj) returns the class namespace specified for the model. Class namespaces can help to prevent name conflicts in large projects.

Examples

collapse all

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 access the namespace of the model, use the getClassNamespace function. If you did not specify a namespace for the model, the getClassNamespace function returns an empty character vector.

name = getClassNamespace(cm)
name =

  'TopNS'

Specify a namespace for the model by using the setClassNamespace function.

setClassNamespace(cm, 'myClassNamespace');

The getClassNamespace function now returns the specified class namespace.

name = getClassNamespace(cm)
name =

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

Output Arguments

collapse all

Class namespace of model, returned as a character vector. If you did not specify a namespace for the model, the getClassNamespace function returns an empty character vector.

Introduced in R2021a