sgratiy wrote:First question: Is this the proper way of defining a list of cells?
It may work, but it's good to move even farther away from "subscripted object names." Better to append each new instance at the time that you create it. In pseudocode, if you need N cells,
Code: Select all
for i=0,ncells-1
create a new cell instance
append this to the list of cells
or better yet, create a function makecell that returns an instance of the class, and
Code: Select all
for i=0,ncells-1
cells.append(makecell)
where cells is the name of the list of cells.
I want to access sections of a particular cell from a member function of this class.
A well-written cell class definition will have a member called "all". During creation of a new instance of such a class, each section that belongs to the new instance is appended to "all". So if foo is the name of an instance of that class, you can iterate over the contents of foo.all.
If you use the CellBuilder to make a toy model cell (ball & stick will do), then use its Management page to export a "Cell Type" you'll get a hoc file that will show you exactly how the "all" set is created and configured.
Do I understand correctly that
will go over all sections of all cells and cannot be applied to a particular cell from the list?
I believe that is the case. It's easy enough to test--just make two instances of a class and then see what for sec in h.allsec() does.
The only thing I can think of is . . .
You're on the right track. Use the CellBuilder, as suggested above, to generate some hoc code that will show you exactly how to structure your template.