3.2.3. Abstract interface header file

To call methods of the abstract interface class, the C++ code must know the class declaration of the abstract interface class. This class definition is generated automatically by Simulator Generator into the directory that contains all source files generated by System Canvas. The name of the header file and the name of the abstract interface class is protocol_ProtocolName.h where ProtocolName is the name of the protocol for this abstract interface. There is one generated header file for each protocol in the system. The header file is always generated, even if it is not used by C++ code. In the example in Figure 3.4, the C++ component header file is protocol_myInterface.h.

The abstract interface class and the header file is generated directly from the protocol definition in the LISA+ file. The interface class contains all behaviors of the protocol (master or slave) as virtual member functions that are in the same order as in the LISA+ protocol definition. Function names, parameters, return type and order are exactly the same in the LISA+ protocol definition and in the generated abstract interface class.

C++ code that is to be compiled independently of the LISA+ code can take a copy of this generated header file. By taking a copy of the header file, both the C++ code and the LISA+ code agree on the interface. This is exactly the same as the interface agreement between two C++ modules.

Whenever the LISA+ protocol definition is changed, the abstract interface class also changes and the interface header file used by the C++ code must also be updated.

If the C++ code includes the abstract interface header file and receives a pointer to such an interface, it can call any of the interface methods. The semantics of such an invocation depend on the type of port the abstract interface belongs to and its implementation.

Invoking a function in the abstract interface typically has the same semantics as if the LISA+ component containing the port invoked the corresponding behavior locally.

If the abstract interface belongs to a slave port, or an internal port that is not connected to any other ports, and the port implements the slave behaviors of the protocol, the C++ code can call all the slave behaviors on the port. This is the most typical use case.

For example, the LISA+ component can use a specific protocol to communicate with the C++ component. It can also give the C++ code access to certain resources by providing access functions for these resources in the protocol. The only purpose of such a protocol would be to communicate with a C++ code.

If the abstract interface belongs to a master port that is connected to one or more slave ports, invoking a function on the abstract interface results in calls to all slaves connected to the master port. If no slave is connected to the master port, or if none of the connected slaves implement the behavior being called, the results are undefined.

Copyright © 2007-2009 ARM Limited. All rights reserved.ARM DUI 0372G