Blueprint Help Send comments on this topic.
Inheritance

Glossary Item Box

Overview

Inheritance is an important OO concept that allows existing objects to be extended and modified.  Although inheritance is not supported directly at present, the same effect can be achieved manually.  Inheritance is simulated by instantiating the base circuit within the derived circuit and connecting its instance pins to the derived circuit's definition pins.  Overriding, abstract and virtual methods are also easily achieved.

Deriving From a Base Class

Deriving from a base class consists of the following steps:

  1. Instantiate a base instance within the derived definition
  2. Create a mandatory pin on the derived definition for each mandatory pin on the base instance
  3. Create reference connections from the derived definition pins to the base instance pins

This creates a new definition that has exactly the same behavior and interface as the base.  However, you will want to modify this to add additional functionality.

Overriding a Base Event

Overriding a base event involves deleting the connection from the base instance pin to the derived definition pin, deleting the definition pin and connecting the instance pin to some internal circuitry that provides the required behavior, which could just be a method or could be something more complicated.

 

Creating an Abstract Event

Creating an abstract event is achieved by simply providing an event via a mandatory definition pin.  The instantiator must supply consuming circuitry to handle the event:

 

Creating a Virtual Event

Creating a virtual event is more complex than creating an abstract event because the circuitry must provide a fall-back in the case where it is not overridden.  This is achieved by making a connection between the default consumer and the definition provider pin.  The default handler connection point is represented using a small white box with the name of the corresponding pin next to it:

 

If we modify the above to specify the instance pin of a base circuit as the default handler, we are effectively overriding the base event but making it virtual so that it can be overridden again.