3.1.4 LISA+ example of accessing C++ constructs

A commented LISA+ example demonstrating the concepts necessary to communicate with C++.

component MyComponent{
includes
    {
       // make C++ declarations visible in behaviors and resources
        #include "MyCPPComponent.h"
    }

    resources
    {
        MyCPPComponent *mycomp;        // declare a pointer to a C++ class
    }

    // use this internal port to allow the C++ code to talk to us
    internal port<MyInterface> callback
    {
    behavior signal()
        {
            // the C++ code can call this behavior 
        }
    }

    behavior init
    {
         // create instance of C++ class. We pass a pointer to the 'callback'
         // port to allow the C++ code to call us back
         mycomp = new MyCPPComponent(callback.getAbstractInterface());
    }

    behavior reset(int level)
    {
        // LISA+ code can call C++ code directly without any special
        // syntax
        mycomp->reset();
    }

    behavior terminate
    {
            delete mycomp;            // delete instance of C++ class
    }
}

// use this protocol to allow the C++ code to call the LISA code protocol 
MyInterface{
    behavior signal();
}
Non-ConfidentialPDF file icon PDF version101092_0100_04_en
Copyright © 2014–2018 Arm Limited or its affiliates. All rights reserved.