How to inherit a class
OOP is not OOP without inheritance. Let's make a descendant of the person class. You can inherit a class by calling obj_inherit(classname) in the init() function. You can inherit from multiple classes.
Let's define a german class inherited from person class. And let's override the sayhello method:
You can type in the following and try clicking sayhello button.
oop_new("root:albert", "german")
oop_call("root:albert", "edit")
The overridden method will be called.
To call sayhello method programmatically, you use:
oop_call("root:albert", "sayhello")
Then you get:
Hallo, mein Name ist Jack. Wie geht es Ihnen?
If you call:
oop_call("root:jack", "sayhello")
You get:
Hello, my name is Jack . How are you doing?
That is, oop_call (objpath, methodname) implements virtual method call.
There are other variants of oop_call functions depending on return type(number or string) and arguments number and types:
oop_call_s(obj, method, sarg1)
oop_call_v(obj, method, varg1)
/s oop_s_call(obj, method)
oop_call_ss(obj, method, sarg1, sarg2)
/s oop_s_call_svv(obj, method, sarg1, varg2, varg3)
etc.
Functions in this example
More Details
- For more about GUI panel and GUI description rules see
IgorOOPGuiBasics
- For more about inner workings of Igor OOP see
IgorOOPBasics
- You can always explore the source code for actual usage examples.
Back To
IgorOOP