next up previous contents
Next: The Wire Class Up: Classification of Circuit Components Previous: The Component_List Class

The Connector Class

The Connector class is responsible for connecting components together and for connecting components with the outside world. In circuit description, there are two type of connectors, namely wires and ports. The Connector class will be used as an abstract base class from which a Wire class and a Port class will be derived. These derived classes will be covered in a later section. The class declaration for Connector is as follows:

class Connector
{
public:
        Connector(char* = "Connector");
        void            connect(Component *);
        virtual Signal  get_Signal(ckt_time) = 0;
        virtual void    send_Signal(Signal) = 0;
protected:
        Component_List  fan_out;
        char            *name;
};

The constructor for Connector trivially assigns the character pointer passed in to its protected name data member:

Connector::Connector(char *nm) : 
        name(nm)
{ }

The connect() method is responsible for taking a pointer to a component and adding it to the fan-out of the connector.

void
Connector::connect(Component *cmp)
{
        fan_out.add(cmp);
}

The get_Signal() and send_Signal() virtual methods are related to the transmission of signals which occurs during simulation, and are therefore discussed in the next chapter. These two virtual methods are defined as pure virtual functions by assigning them to zero. Doing this prevents an object of type Connector from being instantiated in the code. Note that this does not preclude the creation of objects from classes derived from Connector, just as long as they override both virtual methods in their class declaration.

Since a connector can supply signals to one or more components, the Connector class is responsible for maintaining a linked list of pointers to components, referred to by the fan_out data member. Since the Wire and Port class require access to the fan-out of the connector, fan_out is made a protected member of the class. The Component_List class which is used to instantiate fan_out was described in the previous section.



Donald Craig
Sat Jul 13 16:02:11 NDT 1996