ObjectOrientedProgramming

general
   begintemplate  external       objectvar      public         
   endtemplate    new            objref         
See Object Oriented Programming in the reference manual.


begintemplate

ObjectOrientedProgramming

SYNTAX

begintemplate

DESCRIPTION

Declare a new class or data structure. Any HOC code may appear between the begintemplate and endtemplate declarations. Classes are instantiated with the new statement.

EXAMPLES

begintemplate String
public s
strdef s
 proc init() {
   if (numarg()) {
     s = $s1
   }
 }
endtemplate String
objref s
s = new String("Hello")
print s.s
will print "Hello" to the screen.


endtemplate

ObjectOrientedProgramming

SYNTAX

endtemplate

DESCRIPTION

Closes the class declaration

SEE ALSO

begintemplate


objectvar

ObjectOrientedProgramming

SYNTAX

objectvar

DESCRIPTION

Synonym for objref .


objref

ObjectOrientedProgramming

SYNTAX

objref

DESCRIPTION

A comma separated list declarations of object variables. Object variables are labels (pointers, references) to the actual objects. Thus o1 = o2 merely states that o1 and o2 are labels for the same object. Objects are created with the new statement. When there are no labels for an object the object is deleted. The keywords objectvar and objref are synonyms.

An object has a unique name that can be determined with the print obj statement and consists of the template name followed by an index number in brackets. This name can be used in place of an objref.

EXAMPLES

objref vec, g
vec = new Vector(20)
g = new Graph()
creates a vector object and a graph object with pointers named vec and g, respectively.

SEE ALSO

new , begintemplate , List , pointprocesses , SectionList


public

ObjectOrientedProgramming

SYNTAX

public

DESCRIPTION

A comma separated list of all the names in a class that are available outside the class.

SEE ALSO

begintemplate


external

ObjectOrientedProgramming

SYNTAX

external

DESCRIPTION

A comma separated list of functions, procedures, or iterators defined at the top level that can be executed within this class. This statement is optional but if it exists must follow the begintemplate or public line. This allows an object to request information from the outside.

EXAMPLES

global_ra = 100
 func ra_value() {return global_ra}
begintemplate Cell
 external ra_value
 create axon
 proc init() {
	forall Ra = ra_value()	/* just the axon */
 }
endtemplate Cell

If needed, this can be expanded to allow other kinds of variables to be external. execute1 can be used to obtain external information as well.


new

ObjectOrientedProgramming

SYNTAX

objectvariable = new Object(args)

DESCRIPTION

Creates a new object/instance of type/class Object and makes objectvariable label/point to it. When the object no longer is pointed to, it no longer exists.

EXAMPLES

objref vec
vec = new Vector(30)
creates a vector of size 30 with its pointer named vec.


neuron/general/oop.hel : Dec 7 11:07