File: secref.rst

package info (click to toggle)
neuron 8.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,760 kB
  • sloc: cpp: 149,571; python: 58,465; ansic: 50,329; sh: 3,510; xml: 213; pascal: 51; makefile: 35; sed: 5
file content (232 lines) | stat: -rw-r--r-- 4,764 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232

.. _hoc_secref:

SectionRef
----------



.. hoc:class:: SectionRef


    Syntax:
        ``section sref = new SectionRef()``


    Description:
        SectionRef keeps a pointer/reference to a section 
        The reference is to the currently accessed section at the 
        time the object was created. 
         
        This class allows sections to be referenced as normal object variables 
        for assignment and passing as arguments. 


----



.. hoc:method:: SectionRef.sec


    Syntax:
        ``sref.sec``


    Description:
        special syntax that makes the reference the currently 
        accessed section. 
        This class allows sections to be referenced as normal object variables 
        for assignment and passing as arguments. The usage is 

        .. code-block::
            none

            create soma, axon 
            axon.diam=2 
            soma.diam=10 
            access axon 
            objref s1, s2 
            soma s1 = new SectionRef()	// s1 holds a reference to the soma 
            print s1.sec.diam		// print the diameter of the soma 
            s2 = s1				// s2 also holds a reference to the soma 
            s2.sec { psection() }		// print all info about soma 
            axon s2 = new SectionRef() 
            proc c() { 
            	$o1.sec connect $o2.sec(0), 1 
            } 
            c(s1, s2) 
            topology() 

        This last is a procedure that takes two SectionRef args and 
        connects them end to end. 


----



.. hoc:method:: SectionRef.parent


    Syntax:
        ``sref.parent``


    Description:
        parent of sref.sec becomes the currently accessed section. Generally it 
        is used in a context like \ ``sref.parent { statement }`` just like a 
        normal section name and does NOT need a section_pop 
        If there is a chance that a section does not have a parent then 
        :hoc:meth:`SectionRef.has_parent` should be called first to avoid an execution error.
        Note that the parent is the current parent of sref.sec, not necessarily 
        the parent when the SectionRef was created. 


----



.. hoc:method:: SectionRef.trueparent


    Syntax:
        ``sref.trueparent``


    Description:
        trueparent of sref.sec becomes the currently accessed section. 
        This is normally identical to :hoc:meth:`SectionRef.parent` except when the
        parent's :hoc:func:`parent_connection` is equal to the parent's
        :hoc:func:`section_orientation`.
        If there is a chance that a section does not have a trueparent then 
        :hoc:meth:`SectionRef.has_trueparent` should be called first to avoid an execution error.


----



.. hoc:method:: SectionRef.child


    Syntax:
        ``sref.child[i]``


    Description:
        the ith child of sref.sec becomes the currently accessed section. 
        Generally it 
        is used in a context like 

        .. code-block::
            none

            for i=0, sref.nchild-1 sref.child[i] { statement } 

        Note that the children are the current children of sref.sec, not necessarily 
        the same as when the SectionRef was created since sections may be 
        deleted or re-connected subsequent to the instantiation of the SectionRef. 


----



.. hoc:method:: SectionRef.root


    Syntax:
        ``sref.root``


    Description:
        root of sref.sec becomes the currently accessed section. 


----



.. hoc:method:: SectionRef.has_parent


    Syntax:
        ``boolean = sref.has_parent``


    Description:
        returns 1 if sref.sec has a parent and 0 if sref.sec is a root section. 
        Invoking sref.parent when sref.sec is a root section will print an 
        error message and halt execution. 


----



.. hoc:method:: SectionRef.has_trueparent


    Syntax:
        ``boolean = sref.has_trueparent``


    Description:
        returns 1 if the sref.sec parent node is not the root node and 0 otherwise. 
        Invoking sref.trueparent when it is the root node will print an 
        error message and halt execution. 


----



.. hoc:method:: SectionRef.nchild


    Syntax:
        ``integer = sref.nchild``


    Description:
        Return the number of child sections connected to sref.sec 

         

----



.. hoc:method:: SectionRef.is_cas


    Syntax:
        ``boolean = sref.is_cas()``


    Description:
        Returns 1 if this section reference is the currently accessed section, 0 otherwise. 

         

----



.. hoc:method:: SectionRef.exists


    Syntax:
        ``boolean = sref.exists()``


    Description:
        Returns 1 if the section has not been deleted, 0 otherwise. 

    .. seealso::
        :hoc:func:`delete_section`, :hoc:func:`section_exists`