Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Smallest object in VFP 7
Message
From
11/12/2001 18:45:21
 
 
To
11/12/2001 03:38:36
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00590364
Message ID:
00593022
Views:
36
awesome, thanks Albert. I hadn't seen "this_access" before!

>You can use the Decorator design pattern to wrap your class in a Session object:
>
>
>#define TABLE_NAME "c:\temp\test.dbf"
>
>set safety off
>set exclusive off
>clear
>
>create table (TABLE_NAME) free (col1 i)
>use (TABLE_NAME)
>select 0
>
>? program(), set("datasession")
>
>loDecorator = createobject("DecoratorSession", createobject("test", TABLE_NAME))
>? program(), set("datasession")
>=loDecorator.populate()
>=loDecorator.list()
>? program(), set("datasession")
>? alias()
>
>define class DecoratorSession as custom
>
>	protected DecoratedObject
>
>	function init( toReference )
>		if vartype(toReference) != 'O'
>			return .f.
>		endif
>		this.DecoratedObject = toReference
>	endfunc
>
>	function this_access( tcMember )
>		* BEWARE - any PEMs of the DecoratedObject that
>		* are duplicated in THIS are inaccessable
>		if pemstatus(this, tcMember, 5)
>			return this
>		else
>			return this.DecoratedObject
>		endif
>	endfunc
>
>	function destroy()
>		this.DecoratedObject = null
>	endfunc
>
>enddefine
>
>define class test as session
>
>	function init( tcTableName )
>		* remember that private datasessions require their own settings
>		set exclusive off
>		use (tcTableName)
>	endfunc
>
>	function populate
>
>		? program(), set("datasession")
>
>		local i, lnCount
>		lnCount = 5
>		for i = 1 to lnCount
>			insert into (alias()) (col1) values (i)
>		endfor
>		return lnCount
>	endfunc
>
>	function list
>
>		? program(), set("datasession")
>
>		scan
>			? col1
>		endscan
>		return reccount()
>	endfunc
>
>enddefine
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform