comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » keyword inheritance and object inheritance
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
keyword inheritance and object inheritance [message #29899] Sat, 23 March 2002 07:04
btupper is currently offline  btupper
Messages: 55
Registered: January 2002
Member
Hi,

I really don't understand how to retrieve object properities when it
comes to multiple object inheritance.

I have ample sources discussing the differences (a very nice thread
from August 2000 in which JD discusses the difference between _Extra
and _Ref_Extra. But this discussion was more about extracting
specific keywords out of the _Extra structure, which can't be done
with the _Ref_Extra, errr, string/structure thingamabob. Liam's book
has nice examples about the difference. David's second edition shows
how to uses thes in his very good chapter on object inheritance. His
book shows how to use the _Ref_extra when you want to get a property.
I also see the online docs which has this little nugget found under
the keyword inheritance section.

> The "pass by reference" keyword inheritance mechanism is especially useful when writing object methods, which may be inherited multiple times and which often wish to change the value of variables available to the calling method. (The values of object properties are one example of data that can profitably be shared by objects at various levels in an object hierarchy.)

So with all that, I feel like I know what I'm doing... but my
performance tells another story.

Below I have included a series of six objects designed to demonstrate
my difficulties.

The first three objects pass keywords by reference (_REF_EXTRA). They
are...

MYOBJ inherits from MOTHER inherits from GRANDMOTHER

The second three pass keywords by value (_EXTRA). They are...

YOUROBJ inherits from FATHER inherits from GRANDFATHER


The GetProperty is the place that 'gets' me. I expect YourObj *not*
to work, since I can't get values back when I pass by value. But I
do expect MyObj to return values because I pass by reference. In a
nutshell, I am unable to retrieve any of the properties of the
Grandmother object through any of the objects which inherit its
properties.

Can anyone help me find my mother (or grandmother?)

The text immediately below is from the output log of a new session.
Following that are thge size objects which can be saved in a procedure
called myobj__define.pro.


Thanks for any and all advice!

Ben


**** Output log starts here*********
IDL Version 5.5, Microsoft Windows (Win32 x86). (c) 2001, Research
Systems, Inc.

IDL> mine = Obj_new('MyObj', 'Mudd', 'Mom', 'Granny')
% Compiled module: MYOBJ__DEFINE.
IDL> yours = obj_new('YourObj', 'Buddy', 'Dad', 'Gramps')
IDL> mine->Help
** Object class MYOBJ, 1 direct superclass, 2 known methods
Superclasses:
MOTHER <Direct>
GRANDMOTHER
Known Function Methods:
MYOBJ::INIT
Known Procedure Methods:
GRANDMOTHER::HELP
Instance Data:
** Structure MYOBJ, 3 tags, length=36, data length=36:
GRANDMA STRING 'Granny'
MOM STRING 'Mom'
ME STRING 'Mudd'
IDL> Yours->Help
** Object class YOUROBJ, 1 direct superclass, 2 known methods
Superclasses:
FATHER <Direct>
GRANDFATHER
Known Function Methods:
YOUROBJ::INIT
Known Procedure Methods:
GRANDFATHER::HELP
Instance Data:
** Structure YOUROBJ, 3 tags, length=36, data length=36:
GRANDPA STRING 'Gramps'
DAD STRING 'Dad'
YOU STRING 'Buddy'
IDL> mine->SetProperty, Grandma = 'Nana', Mom = 'Mum', Me = 'Pooh'
IDL> yours->SetProperty, Grandpa = 'GrandDad', Dad = 'Pops', You =
'Piglet'
IDL> mine->Help
** Object class MYOBJ, 1 direct superclass, 3 known methods
Superclasses:
MOTHER <Direct>
GRANDMOTHER
Known Function Methods:
MYOBJ::INIT
Known Procedure Methods:
GRANDMOTHER::HELP
MYOBJ::SETPROPERTY
Instance Data:
** Structure MYOBJ, 3 tags, length=36, data length=36:
GRANDMA STRING 'Nana'
MOM STRING 'Mum'
ME STRING 'Pooh'
IDL> yours->Help
** Object class YOUROBJ, 1 direct superclass, 3 known methods
Superclasses:
FATHER <Direct>
GRANDFATHER
Known Function Methods:
YOUROBJ::INIT
Known Procedure Methods:
GRANDFATHER::HELP
YOUROBJ::SETPROPERTY
Instance Data:
** Structure YOUROBJ, 3 tags, length=36, data length=36:
GRANDPA STRING 'GrandDad'
DAD STRING 'Pops'
YOU STRING 'Piglet'
IDL> mine->GetProperty, Grandma = Grandma, Mom = Mom, Me = Me
IDL> help, grandma, mom, me
GRANDMA UNDEFINED = <Undefined>
MOM UNDEFINED = <Undefined>
ME STRING = 'Pooh'
IDL> yours->GetProperty, Grandpa = Grandpa, Dad = Dad, You = You
IDL> help, grandpa, dad, you
GRANDPA UNDEFINED = <Undefined>
DAD UNDEFINED = <Undefined>
YOU STRING = 'Piglet'


***** Output log ends here ********

******** OBEJCTS START HERE
;---------Grandfather
;-----
; Getproperty
;-----
PRO Grandfather::GetProperty, Grandpa = Grandpa

Grandpa = self.Grandpa
END ;GetProperty

;-----
; SetProperty
;-----
PRO Grandfather::SetProperty, Grandpa = Grandpa

If n_elements(Grandpa) NE 0 Then Self.Grandpa = String(Grandpa[0])
END ;SetProperty

;-----
; Help
;-----
PRO Grandfather::help

Help, self, /obj
END ;Help

;-----
; Init
;-----
FUNCTION Grandfather::init, Grandpa, _Extra = extra

If n_elements(Grandpa) NE 0 Then self.Grandpa = String(Grandpa[0])
Return, 1
END ;init

;-----
; CleanUp
;-----
PRO Grandfather::Cleanup

END ;cleanup

;------
;Define
;------
PRO Grandfather__Define

struct = {Grandfather, $
Grandpa:''}

END ;Define



;---------Father

;-----
; GetProperty
;-----
PRO Father::GetProperty, Dad = Dad, _Extra = Extra

Dad = Self.Dad
Self->Grandfather::GetProperty, _Extra = extra
END ; GetProperty

;-----
; SetProperty
;-----
PRO Father::SetProperty, Dad = Dad, _Extra = Extra

If n_elements(Dad) NE 0 Then Self.Dad = string(Dad[0])

Self->Grandfather::SetProperty, _Extra = extra
END ; SetProperty

;------
; Init
;------
FUNCTION Father::Init, Dad , Grandpa,_Extra = extra
If Self->Grandfather::INIT(Grandpa,_Extra = Extra) NE 1 Then Return, 0

If n_elements(Dad) NE 0 Then Self.Dad = String(Dad[0])
Return, 1
END; ;Init

;------
; CleanUp
;------
PRO Father::CleanUp

Self->Grandfather::CleanUp
END ;cleanup

;------
; Define
;------
PRO Father__Define

struct = {Father, $
INHERITS Grandfather, $
Dad: ''}

END ;Father


;--------YourObj

;-----
; GetProperty
;-----
PRO YourObj::GetProperty, You=You, _Extra = Extra

You = Self.You
Self->Father::GetProperty, _Extra = extra
END ; GetProperty

;-----
; SetProperty
;-----
PRO YourObj::SetProperty, You=You, _Extra = Extra

If n_elements(You) NE 0 Then Self.You = string(You[0])

Self->Father::SetProperty, _Extra = extra

END ; SetProperty

;------
; Init
;------
FUNCTION YourObj::Init, You ,Dad, Grandpa, _Extra = extra
If Self->Father::INIT(Dad, Grandpa, _Extra = Extra) NE 1 Then Return,
0

If n_elements(You) NE 0 Then Self.You = String(You[0])
Return, 1
END; ;Init

;------
; CleanUp
;------
PRO YourObj::CleanUp

Self->Father::CleanUp
END ;cleanup

;------
; Define
;------
PRO YourObj__Define

struct = {YourObj, $
INHERITS Father, $
You:''}

END




;---------Grandma
;-----
; Getproperty
;-----
PRO grandmother::GetProperty, grandma = grandma

grandma = self.grandma
END ;GetProperty

;-----
; SetProperty
;-----
PRO grandmother::SetProperty, grandma = grandma

If n_elements(grandma) NE 0 Then Self.grandma = String(grandma[0])
END ;SetProperty

;-----
; Help
;-----
PRO grandmother::help

Help, self, /obj
END ;Help

;-----
; Init
;-----
FUNCTION grandmother::init, grandma, _Extra = extra

If n_elements(Grandma) NE 0 Then self.grandma = String(grandma[0])
Return, 1
END ;init

;-----
; CleanUp
;-----
PRO grandmother::Cleanup

END ;cleanup

;------
;Define
;------
PRO grandmother__Define

struct = {grandmother, $
Grandma:''}

END ;Define



;---------Mother

;-----
; GetProperty
;-----
PRO mother::GetProperty, mom = mom, _Ref_Extra = Extra

mom = Self.mom
Self->grandmother::GetProperty, _Extra = extra
END ; GetProperty

;-----
; SetProperty
;-----
PRO mother::SetProperty, mom = mom, _Ref_Extra = Extra

If n_elements(Mom) NE 0 Then Self.mom = string(mom[0])

Self->grandmother::SetProperty, _Extra = extra
END ; SetProperty

;------
; Init
;------
FUNCTION mother::Init, mom , grandma,_Ref_Extra = extra
If Self->grandmother::INIT(grandma,_Extra = Extra) NE 1 Then Return, 0

If n_elements(mom) NE 0 Then Self.mom = String(Mom[0])
Return, 1
END; ;Init

;------
; CleanUp
;------
PRO mother::CleanUp

Self->grandmother::CleanUp
END ;cleanup

;------
; Define
;------
PRO mother__Define

struct = {mother, $
INHERITS grandmother, $
mom: ''}

END ;mother


;--------MyObj

;-----
; GetProperty
;-----
PRO myobj::GetProperty, me=me, _Extra = Extra

me = Self.me
Self->mother::GetProperty, _Extra = extra
END ; GetProperty

;-----
; SetProperty
;-----
PRO myobj::SetProperty, me=me, _Ref_Extra = Extra

If n_elements(Me) NE 0 Then Self.Me = string(me[0])

Self->mother::SetProperty, _Extra = extra

END ; SetProperty

;------
; Init
;------
FUNCTION myobj::Init, me ,mom, grandma, _Ref_Extra = extra
If Self->mother::INIT(mom, grandma, _Extra = Extra) NE 1 Then Return,
0

If n_elements(Me) NE 0 Then Self.Me = String(Me[0])
Return, 1
END; ;Init

;------
; CleanUp
;------
PRO myobj::CleanUp

Self->mother::CleanUp
END ;cleanup

;------
; Define
;------
PRO myobj__Define

struct = {myobj, $
INHERITS mother, $
Me:''}

END
********OBEJCTS END HERE
[Message index]
 
Read Message
Previous Topic: MPEG
Next Topic: Re: keyword inheritance and object inheritance

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:58:14 PDT 2025

Total time taken to generate the page: 0.00500 seconds