Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you have Singleton objects in VFP?
Message
From
22/07/2003 08:57:51
 
 
To
13/07/2003 14:29:22
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00808442
Message ID:
00812317
Views:
21
Thanks for your help on this, I have decided to use a similar model to the one below.

Thanks
Kev

>>Yes, I was thinking of having a class that could return references to it's own instances of the required classes.
>
>In VFP8 it seems simple.
>
>
>public goFactory
>goFactory = CREATEOBJECT("cusFactory")
>
>DEFINE CLASS cusFactory as Custom
>	ADD OBJECT ioSingleton as "collection"
>	FUNCTION new(tcClass,tcLib)
>		WITH THIS
>			IF .ioSingleton.GetKey(tcClass) = 0
>				DEBUGOUT "create object"
>				.ioSingleton.Add(NEWOBJECT(tcClass,tcLib),tcClass)
>			ENDIF
>			DEBUGOUT "return reference"
>			RETURN .ioSingleton(tcClass)
>		ENDWITH
>	ENDFUNC
>ENDDEFINE
>
>
>You could hang the factory off _SCREEN, or your own goApp object, however you manage such things.
Previous
Reply
Map
View

Click here to load this message in the networking platform