Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing a parent's object
Message
De
27/08/2007 15:10:11
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
01250681
Message ID:
01250733
Vues:
18
Just had a thought. What about using AddObject (or something like that) in the oxServer that creates the oHandler object, instead of passing it in? Or is that like having two mirrors facing one another?

>You could add a ParentObject property to emulate the Parent property of a container, so you can do
>
>
>oxHandler = CREATEOBJECT( "EMPS_Handler_Medinotes_Class", this)
>oxServer = CREATEOBJECT( "EMPS_Server_Class", this )
>
>
>in both your classes, you have a ParentObject property, and in the Init you do:
>
>
>function Init(toParentObject as Object) as Boolean
>	this.ParentObject			= toParentObject
>endfunc
>
>* Do not forget the Destroy!
>procedure Destroy() as VOID
>	this.ParentObject			= null
>endproc
>
>
>Now, both, oxHandler and oxServer can interact which each other thru their ParentObject Property, for example oxHandler can use this.ParentObject.oxServer.Port
>
>Of course, this is not a very good thing to do from an Object Oriented viewpoint, I wish my memory could remember what is the name of the rule we are violating here, but it should work <g>
>
>A better way (well, at least I think) would be that the Parent object is the guy handling all the events, like, lets say you still use ParentObject in both classes, but you never use oxServer or oxHandler from any methods in oxServer or oxHandler, instead, for example, frome the Acknowledgement procedure of oxHandler you just call this.ParentObject.Acknowledge([Parameters]) (which does have access and knowledge of it's childs) and the same with each method of this child objects that need some info from the other object
>
>>Agreed. Any ideas?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform