The Component_List class, as used later, maintains a linked list of components which may be present in the fan-out of a connector. The definition of the class is as follows:
class Component_List { public: Component_List(); void add(Component *); boolean is_empty(); void propagate();
private: Component_Node *comp_list; };
This class contains a public constructor which has no parameters (a default constructor). The constructor sets the pointer to the head of the list, comp_list, to null.
Component_List::Component_List() : comp_list(0) { }
The add() method accepts a pointer to a component and simply adds it to the linked list of component pointers.
void Component_List::add(Component *c) { Component_Node *nc = new Component_Node(c); nc->next = comp_list; comp_list = nc; }
The Component_Node class is simply a class which contains a pointer to a component and a pointer to the next element in the list. All the data elements in this class are made private. Component_List is made a so-called friend of Component_Node so that Component_List is the only class which may access the members of a Component_Node class.
The is_empty() and propagate() methods, being related more closely to circuit simulation, are discussed in the next chapter.