gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnucap-devel] Need clarification regarding public functions from cl


From: al davis
Subject: Re: [Gnucap-devel] Need clarification regarding public functions from class CARD_LIST
Date: Thu, 31 Jul 2014 20:03:36 -0400
User-agent: KMail/1.13.7 (Linux/3.2.0-4-amd64; KDE/4.8.4; x86_64; ; )

On Thursday 31 July 2014, Rishabh Yadav wrote:
> What does set_owner(CARD* owner) and clone() public member
> function from class CARD_LIST do?

clone() makes a copy of itself.

_owner is a back pointer.  It points back to the object 
containing this one.

Suppose you have a subcircuit, with a bunch of things inside.  
For each of those things inside, the _owner is the thing they 
are inside of.

Not to be confused with _parent, which is someone who shares 
your DNA.  In gnucap, the _parent is the object that was cloned 
to make this one.  Usually in gnucap when objects are cloned, 
the clone is a "shallow copy" of the parent.  

A "shallow copy" just copies pointers sharing data with parent 
and siblings.  The opposite of "shallow" is "deep".  A "deep 
copy" of an object copies everything, including recursively 
copying things attached by a pointer.

Back to _owner ...  in a CARD_LIST, the _owner is a CARD that 
owns it.  The most obvious case here is a subckt.  A subckt 
instance is a CARD, which has a CARD_LIST.  That CARD_LIST and 
all of the CARDs in it have the same _owner.

The root circuit has no _owner.  Commands in the root scope 
(which is all we have for now) have no _owner.

Devices inside a subcircuit are owned by the DEV_SUBCKT.  Some 
other devices may also have internal subcircuits, most 
significantly the ones defined in .model files that are 
processed through modelgen.

What it is used for? ....  mostly parameter evaluation and 
device searching.  It is a hook back to an enclosing scope.

What to set_owner to? .... For the loop and conditional 
commands, you are storing DEV_DOT's in a CARD_LIST.  Where is 
that CARD_LIST attached?  If it is attached to some CARD, that's 
the _owner.  If it isn't attached to some CARD, how are you 
keeping track of it?  There is only one CARD_LIST that is not 
attached to some CARD.  That's CARD_LIST::card_list, the root 
circuit.  For things placed there, the _owner is NULL.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]