Main Content

getClassNamespace

Get class namespace for a model

Since R2021a

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('CppClassRateBased');
cm = coder.mapping.api.get('CppClassRateBased');

Use the getClassNamespace function to access the namespace of the model.

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

name = getClassNamespace(cm)
name = 
'example_ns'

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.

Version History

Introduced in R2021a