You copied the Doc URL to your clipboard.

Obtaining a custom interface

This section describes how to ensure the correct functionality of an acquired interface and to avoid, for example, the utilization of an outdated interface revision.

The procedure of obtaining a custom interface is the same as the one for the standard interfaces:

  1. A CAInterface pointer to the target interface class is required. The CADI simulation typically returns this pointer.
  2. The ObtainInterface() method must be called to check if the required interface is provided.
  3. The returned pointer to CAInterface, which might differ from the originally obtained one, must be converted to a pointer to the requested interface class by using a static_cast().

    Using CADISimulation to return a pointer to the interface, using MyExtensions and MyCADI classes implementations
    CADISimulation* cadiSimulation;
    uint32_t targetID;
    CAInterface* ca_interface;
    MyExtensions* my_extensions_if;
       // Get the CADISimulation pointer.
    // Here, gets a pointer of type CAInterface. this pointer can be used to obtain
    // any interface provided by the target using ObtainInterface().
    ca_interface = cadiSimulation->GetTarget(targetID);
    //obtain the desired interface
    if_name_t ifName = "MyExtensions";
    if_rev_t  minRev = 0;
    if_rev_t  actualRev = 0;
    // ObtainInterface() asks for "MyExtensions" interface.
    // It returns the corresponding base class pointer.
    ca_interface = ca_interface->ObtainInterface(ifName, minRev, &actualRev);
    if (ca_interface == NULL)
       // Something went wrong, handle it...
    else // MyExtensions interface supported.
       my_extensions_if =
          .   //go on using the obtained interface extensions 
Was this page helpful? Yes No