| |||
| Home > The CADI Extension Mechanism > Overview of the extension mechanism |
One of the major features introduced with CADI 2.0 is the extension mechanism that:
provides a simple framework that enables adding more interfaces to a target component
enables checking compatibility between the caller and the target.
A single target can present multiple interfaces. Each of the
interfaces, including the basic CADI interface,
is an extension of the abstract CAInterface class.
The client can use a pointer to any of the interfaces to obtain
a pointer to any of the other interfaces implemented by the target.
The CADI extension mechanism is based on the CAInterface class
and its methods that must be implemented for any custom interface:
IFNAME()is a static method that must be defined by each interface class. It returns the name.
IFREVISION()is a static method that must be defined by each interface class. It returns the revision.
ObtainInterface()is a virtual method that is implemented in the class that implements the interface. It retrieves an interface from a target, including those introduced by an extension, and performs compatibility checks.
The main work of adding a custom extension to CADI must be done in the implementation for the target. A new class is declared and implemented provides access to all interfaces the target component offers.
A typical implementation requires consideration of the following:
Declare a class with the custom interface extensions
that must be derived from CAInterface. The inherited
method calls must be implemented.
Implement ObtainInterface() for
the custom extension such that all existing interface are accessible.
Other implemented interfaces provided by the target
require a link to the extension through their ObtainInterface() implementations.
Implementation example for extending the target-side provides an example of creating and implementing an extension interface.