You copied the Doc URL to your clipboard.

Scope of behaviors

Component behaviors and port behaviors are both in the scope of the component and can directly access the resources of the component.

Behaviors that want to return pointers or instances of types that are defined in the resources section of the same component must use the COMPONENT_CLASS_NAME() construct to access the type in the resource section. COMPONENT_CLASS_NAME(x) represents the scope of component x, and when returning a pointer or an instance of a type that is declared in the resources section of component x, you must explicitly specify this scope when specifying the return type of the behavior.

Component scope with COMPONENT_CLASS_NAME(x)
component MyComponent
{
    resources
    {
        struct status_t
        {
            int i;
        };
        status_t status;
    }

    behavior getStatus():status_t  // Incorrect: status_t is unknown outside the behavior.
    {
        return status;
    }

    behavior getStatus(): COMPONENT_CLASS_NAME(MyComponent)::status_t  // Correct: prefix the return type with the scope.
    {
        return status;
    }
}
Was this page helpful? Yes No