[Ktechlab-devel] Pin breakthrough

Alan Grimes agrimes at speakeasy.net
Sun Oct 18 02:25:03 UTC 2009


I achieved something of a breakthrough today with class Pin. It now
knows nothing at all about Switches. Switches now work by adding and
removing wires between their pins. This is a vastly more elegant
solution. =P

Really, to close a switch the code is merely:

foo = new Wire(pinA, pinB).

and to open the switch,

delete foo;

That's all there is to it, basically. ;)

It still doesn't look right to have pin contain sets of pointers to
itself. However this is the core of the code that creates subcircuits
for simulation.

I spent the morning studying the Zoltan code and concluded that I was
basically right, that there shouldn't be a loop to delete wires there
(and that's why it was segfaulting.). What I did put there was an
assertion check to make sure the e-connector was correctly removed from
the circuit. If ECNode is implemented correctly, then pins should be
told that the wire is gone, which should safely start the process that
deletes the wire.

For the same reason, there is no destructor in Switch because the act of
deleting the switch will delete its pins which will delete all
associated wires.

-- 
New president: Here we go again...
Chemistry.com: A total rip-off.
Powers are not rights.





More information about the Ktechlab-devel mailing list