Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing a parent's object
Message
 
À
27/08/2007 13:50:01
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:
01250728
Vues:
18
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?
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform